ID:183714
 
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
var currentlocation = document.URL

Found via http://www.w3schools.com/js/default.asp
In response to Crispy
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!
In response to Upinflames
clol is a string, you're not treating it as a string in your if conditional. if(clol == "index.html") should fix the error.
In response to Nadrew
nope no luck
heres the new code

var clol = document.URL
var thing = "hey"
if (clol = "index.html")
{
document.write(thing)
}
In response to Upinflames
Upinflames wrote:
nope no luck
heres the new code
>

var clol = document.URL
var thing = "hey"
if (clol = "index.html")
{
document.write(thing)
}
>


You cannot do == in between strings IIRC
In response to Upinflames
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: ==
In response to Shlaklava
ok i added that in the ==(thanks shlaklava for that i missed that) but it's still not working
In response to Upinflames
Upinflames wrote:
ok i added that in the ==(thanks shlaklava for that i missed that) but it's still not working

If it is still not returning the right results from the if() test then it is because a function might be needed to test the strings.