473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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. }
  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 2074
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

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

Similar topics

8
by: alanstew | last post by:
With the body tag calling out 'window onload', a function with a 'window.open' fails at the 'window.open' line. If I cut out the body tag, the function executes as normal. At first I thought it...
10
by: pmelanso | last post by:
Hello, How can I tell if there is a page to go back to in the history or not??? Same with forward??? say something like/// if (there is a page to go back to ) { // DO something }else { }
2
by: Brian Mitchell | last post by:
I want to implement a logoff feature in my ASP.NET application (using VB), but how do I expire or delete the pages from the cache so another user can't simply use the back arrow to bring the pages...
3
by: MarkMurphy | last post by:
I have a simple export.aspx page that allows a user to fill in a form to export some data. The postback logic writes the data to the response stream. I have two small issues: 1) The data is...
4
by: PJ6 | last post by:
After logging out of my test site I would like to be able to not allow the user to navigate back to previous pages. It's not super-important because if they try to do anything the login state has...
20
by: Dan | last post by:
Is there a way to obtain the last page visited? I don't want to go to that page, I just want to be able find out what page they came from, the url of that page. Is this possible?
3
by: pentisia | last post by:
Hi there, We are using history.go(integer) to go back to the certain page directly. Because there are some pages interaction in between. For example, starting from page 1 to page 2. From page...
12
by: jim.richardson | last post by:
Hi all, I'd like a page to be excluded from the back button history, that is, when a user hits their browser's back button, it never backs into this particular page. Can anybody please tell...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.