Click to See Complete Forum and Search --> : Reading URL


Vaston
01-16-2004, 07:53 PM
Hey
I need a script where it reads the url and depending on what the url is display a certain code. Like if i click a link test.html#1 it will show only that certain code and same if its test.html#2. I dont want it through <a name=""> either as you can see the other coding.

Possible Psuedo Code:
IF URL="test.html#1" THEN
2.style.visibility="hidden";
1.style.visibility="visible";
ELSEIF URL="test.html#2" THEN
1.style.visibility="hidden";
2.style.visibility="visible";
END IF

Thanks
-Vaston

AdamGundry
01-17-2004, 02:42 AM
Try something like this (bear in mind your page needs to be accessible with Javascript disabled):

if (location.hash == '#1'){
// Do something
} else if (location.hash == '#2'){
// Do something else
}

Adam