468,792 Members | 1,725 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,792 developers. It's quick & easy.

Preventing doc.write() on history.back

Hello all,

I am trying to change a line of text when a user uses the back button to return to a page what I have at the moment is this:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. if(window.location == window.location){
  3.     document.write( "<h1>Hello There</h1>" );
  4. }
  5.  
  6. else if(window.history.back(-1) == window.location){
  7.      document.write("<h1>welcome back</h1>");
  8. }         
  9. </script>
  10. </head>
  11. <body>
  12.     <p><a href="index.html" >Forward</a></p>
  13. </body>
  14. </html>
It will write to the page but when I click the Forward link and then the browser back button I am still getting the first document.write() called.

Any help with this will be greatly appreciated.

K
Sep 12 '07 #1
2 1873
epots9
1,351 Expert 1GB
of course, cuz your testing if the address bar equals the address bar, its going to be true. what you would want to try using for something like this are cookies.
Sep 12 '07 #2
pbmods
5,821 Expert 4TB
Heya, K. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE=javascript]
JavaScript code goes here.
[/CODE]
Sep 12 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by pmelanso | last post: by
2 posts views Thread by Brian Mitchell | last post: by
3 posts views Thread by MarkMurphy | last post: by
20 posts views Thread by Dan | last post: by
3 posts views Thread by pentisia | last post: by
12 posts views Thread by jim.richardson | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.