Forum Moderators: open

Message Too Old, No Replies

Assignment not working correctly

         

Nymme

7:12 pm on Aug 20, 2010 (gmt 0)

10+ Year Member




locations = window.location.href.split('?');
location = locations[0];
alert(location);
alert(locations[0]);


I have a javascript function that uses this chunk of code (the alerts are for testing only). location and locations[0] are coming out different from each other. Any thoughts on what could be going wrong would be greatly appreciated.

Thanks in advance

Fotiman

7:58 pm on Aug 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



"location" is a bad choice for variable name, as it might use the window.location property, especially since you've not included the "var" before the variables. I suspect that might have something to do with it. When you do location = locations[0], you're probably going to cause the browser to load that new location.

Nymme

8:14 pm on Aug 20, 2010 (gmt 0)

10+ Year Member



Apparently that was the problem, thanks for the help.