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.
Sit
You can use substr
for example:
new Date().getFullYear().toString().substr(-2)
you can also quote string
''+document.location+''.substring(2,3);
try this code below :
var currentLocation = document.location;
muzLoc = String(currentLocation).substring(0,45);
prodLoc = String(currentLocation).substring(0,48);
techLoc = String(currentLocation).substring(0,47);
document.location
is an object, not a string. It returns (by default) the full path, but it actually holds more info than that.
Shortcut for solution: document.location.toString().substring(2,3);
Or use document.location.href
or window.location.href