How can I use JavaScript to get an anchor from the URL?
December 16, 2005 1:30 PM
Subscribe
How can I use JavaScript to get an anchor from the URL?
I think this is called the
hash in JavaScript, but this doesn't work:
var hash=location.hash;
if (hash){
write a hidden form field with the value of hash
}
For example, if I followed a link to
this comment, I'd want to get the value of the comment's anchor, 459821, and write it into a form field.
posted by kirkaracha to computers & internet (4 comments total)
locationobject does have ahashattribute. With which browser are you testing?posted by ijoshua at 1:38 PM on December 16, 2005