Solved

How to window.back() and window.forward()

Posted on 1999-01-27
6
134 Views
Last Modified: 2010-04-09
This code won't work.  What am I doing wrong? I want to click one image to page back and another to page forward. (I don't want to use form buttons.)

<a HREF="#" onClick="window.back()">
<img src="images/back01.jpg"></a>

<a HREF="#" onClick="window.forward()">
<img src="images/for01.jpg"></a>
0
Comment
Question by:adamssr
  • 2
  • 2
  • 2
6 Comments
 
LVL 4

Expert Comment

by:martinag
Comment Utility
Use history, not window:
history.back();
history.forward();

I'd use BORDER="0" for the images. Also, I recommend to put the code in the HREF instead of onClick:

<a HREF="javascript:history.back()"><img src="images/back01.jpg" border="0"></a>
<a HREF="javascript:history.forward()"><img src="images/for01.jpg" border="0"></a>

Martin
0
 

Expert Comment

by:dauma
Comment Utility
adamssr:

Where in the hell did you find window.back or window.forward?  How long have you been programming? :-)

Martin is correct, but this will work also, dude:

<A HREF="javascript:history.go(-1)"><img src="images/back01.jpg" border="0"></A>
<A HREF="javascript:history.go(+1)"><img src="images/for01.jpg" border="0"></A>

You can change the numbers to skip back or forward more spaces in history.

Hope this helps you dude,

Shane.


0
 

Author Comment

by:adamssr
Comment Utility
Martin:
You answered my question first and the 50 points are yours.  But my problem is not solved (my fault). When I inserted your code, it worked, but the onMouseOver and onMouseOut functions I was calling quit working. (I want the button to change onMouseOver).  Here is what I have now:

<a HREF="javascript:history.back()">
<ONMOUSEOVER="act('back');window.status='Back';return true">
<ONMOUSEOUT="inact('back');window.status=' ';return true">
<img src="images/back01.jpg" NAME="back" width="80" height="23" alt="Back" border="0"></a>

What do you suggest?  If you can help me with this, I'll throw in another 50 points.  Thanks..
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Accepted Solution

by:
martinag earned 100 total points
Comment Utility
You've written onMouseOver and onMouseOut as their own tags when they in fact are attributes to the <A> tag:
<a HREF="javascript:history.back()" onMouseOver="act('back');window.status='Back';return true" onMouseOut="inact('back');window.status=' ';return true">

Martin
0
 

Author Comment

by:adamssr
Comment Utility
Thanks, Martin.  I figured it out myself, but you earned the points.

P.S.  A note to Shane:  
The place in hell I found window.forward() was as follows:
<FORM NAME="input">
<INPUT TYPE="button" VALUE="Back" onClick="window.forward()">
</FORM>
0
 

Expert Comment

by:dauma
Comment Utility
onMouseover and onMouseout are not tags.  I suppose you found these in hell, too?

How about this:

<A HREF="javascript:history.go(-1)" onMouseOver="window.status='Back'; return true;"
   onMouseOut="window.status=''"><img src="images/back01.jpg" border="0"></A>
<A HREF="javascript:history.go(+1)" onMouseOver="window.status='Forward'; return true;"
   onMouseOut="window.status=''"><img src="images/for01.jpg" border="0"></A>

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now