In javascript i am making a script to view the current URL using a variable such as
var currentlocation = "the variable i need"
to make it clearer what i mean is i want to store the current location in a string
ID:183714
![]() May 11 2007, 2:30 pm
|
|
ok i used that but now im getting an error i've tried error console but it doesn't help. I will post my code plz help
var clol = document.URL var thing = "hey" if (clol = index.html) { document.write(thing) } Please Help! |
clol is a string, you're not treating it as a string in your if conditional. if(clol == "index.html") should fix the error.
|
nope no luck
heres the new code var clol = document.URL var thing = "hey" if (clol = "index.html") { document.write(thing) } |
Upinflames wrote:
nope no luck > var clol = document.URL > You cannot do == in between strings IIRC |
You're using a single equal sign in your if() statement. A single equal sign means assignment. You don't want that, you want to test equality, for which you need two equal signs: ==
|
Found via http://www.w3schools.com/js/default.asp