471,082 Members | 1,123 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,082 software developers and data experts.

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. }
  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.

Sep 12 '07 #1
2 1925
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
5,821 Expert 4TB
Heya, K. Welcome to TSDN!

Please use CODE tags when posting source code:

JavaScript code goes here.
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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.