Forum Moderators: open

Message Too Old, No Replies

onclick = history.back(); DOM

         

webaster

7:40 pm on Sep 22, 2005 (gmt 0)

10+ Year Member



I need a hand with a DOM script. Thanks for any help in advance.

Have a slideshow navigation and want to put a DOM onubtrusive JS that finds
the <a> in <li id="nav-back">and executes history.back() with a onclick handler. No worry about JS disabled because then I use a other link that is hidden when JS is enabled ...

Some questions-ideas

What do i need to put in the <a href="?"> of <li id="nav-back">?
And the script I started see below, should it be written like that?
History.back() works perfectly cross-browser in DOM capable browsers?

This is the HTML
Code:

<div id="navwrap">
<ul id="nav">
<li id="nav-prev"><a href="#" title="go to previous image">previous</a></li>
<li id="nav-back"><a href="#" title="go to overview of images">back to overview</a></li>
<li id="nav-forward"><a href="#" title="go to next image">next</a></li>
</ul>
</div>

Is this how to do go about it with the script

Code:

if (!document.getElementbyId) {return;} var backButton = document.getElementbyId('nav-back').document.getElementBytagname('a') backButton.onclick = history.back(); }

webaster

7:41 pm on Sep 22, 2005 (gmt 0)

10+ Year Member



Sorry I meant this:

Code:

if (!document.getElementbyId) {return;}
var backButton = document.getElementbyId('nav-back').document.getElementBytagname('a'); backButton.onclick = history.back();

Bernard Marx

8:36 pm on Sep 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[pre]
if (!document.getElementbyId) {return;}
document.getElementbyId('nav-back')
.getElement[b]s[/b]By[b]T[/b]ag[b]N[/b]ame('a')[b][0][/b].onclick = function(){history.back()};
[/pre]