| Calling Javascript function from Anchor Tags Eg: http://www.example.com/index.html#funtion1 would call function1() |
cosmoyoda

msg:3754723 | 6:09 pm on Sep 29, 2008 (gmt 0) | Greetings, I tried searching the forum for an answer on this topic, but I did not find a specific answer. Therefore I decided to start this thread. Hope my question is simple (seems like it is): Is there any possible way to call a function on Javascript from simply changing the anchor (# at the end of the URL address)? I see websites that use Tabs and automatically change to a different tab depending on the anchor tag specified. I want to know if you guys have any ideas how this might be possible using Javascript. Thanks,
|
Fotiman

msg:3754838 | 7:41 pm on Sep 29, 2008 (gmt 0) | You could get the window.location.hash property and perform some action based on the value. var h = window.location.hash; if (h == "#foo") { // do something } else if (h == "#bar") { // do something else }
|
|
|
cosmoyoda

msg:3754940 | 8:04 pm on Sep 29, 2008 (gmt 0) | Fotiman. Thank you for your quick answer! The solution is pretty simple, just how I'd expect it.
|
|
|