KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I don't understand why I get an error message using the substring method to declare a variable. I want to use the first part of the URL in a comparison. Site: http://www.elizabet.nl/wordpress This is the part that's going wrong: var currentLocation = document.location, muzLoc = currentLocation.substring(0,45), prodLoc = currentLocation.substring(0,48), techLoc = currentLocation.substring(0,47); The error: "currentLocation.substring is not a function" But this part of the code is fine: var URL = $(this).attr("href").substring(2) + ' #main'; All of the code: jQuery(function($){ var siteURL = "http://" + top.location.host.toString() + "/wordpress", // Declareren van URL van de website. URL = '', // Declareren van een URL, welke dan ook. currentLocation = '', muzLoc = '', prodLoc = '', techLoc = '', allLinks = $('a[href^=' + siteURL + ']' ), // Declareren van alle menu-links. Het teken ^ betekent 'begint met'. otherLinks = $('a[href^=' + siteURL + "/wp-content" + ']'), siteLinks = $(allLinks).not(otherLinks), mainDiv = $("#content"), hash = window.location.hash, muziekURL = "http://www.elizabet.nl/wordpress/#/muziek_pf/", productieURL = "http://www.elizabet.nl/wordpress/#/productie_pf/", techniekURL = "http://www.elizabet.nl/wordpress/#/techniek_pf/"; if (hash) { hash = "/wordpress" + hash.substring(1); // substring methode haalt karakters van je string af. In dit geval de #, vanwege de offset=1. URL = hash; $(mainDiv).load(URL); } function pageLoad() { var allLinks = $('a[href^=' + siteURL + ']' ), otherLinks = $('a[href^=' + siteURL + "/wp-content" + ']'), sit
Tags (comma-separated)
Save Edits
Cancel