Solved

How do I know if user has hit BACK button ?

Posted on 2001-07-12
6
298 Views
Last Modified: 2012-08-13
I have one page, called page1.html.
I visited page1.html first, then I visited another page.
What javascript code can I place in page1.html, so when someone hit BACK
button to go back to page1.html, he/she should see an alert box states that
"you hit BACK" on page1.html ?

p/s : I only want to use javascript, no post or get method.
0
Comment
Question by:johnmemor
6 Comments
 
LVL 6

Accepted Solution

by:
JonFish85 earned 45 total points
ID: 6279023
check this out:

HTML PAGE #1
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Page #1</TITLE>
<SCRIPT language=javascript>
<!--
function CheckIfBack()
{
  if (document.cookie!="")
  {
    alert('back button!');
    document.cookie = "";
  }
}
//-->
</SCRIPT>
</HEAD>
<BODY onload="CheckIfBack();">

<P>&nbsp;</P>

</BODY>
</HTML>





HTML PAGE 2


<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT language=javascript>
<!--
function SetCookie()
{
  document.cookie = "Here";
}
//-->
</script>
</HEAD>
<BODY onload="SetCookie();">

<P>&nbsp;</P>

</BODY>
</HTML>



hope this helps! sorry, ill be out of town till monday if u have problems with this...
0
 

Author Comment

by:johnmemor
ID: 6279316
Can I only use history object, and not cookies ?
0
 
LVL 3

Expert Comment

by:davlun20080
ID: 6279529
No you are not able to see the history, it is a security feature to keep others from knowing the site you just came from, forward or back in the history.

Cookie or server side processing and tracking will need to be set up.
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7910350
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
<note>
   In the absence of responses, I may recommend DELETE unless it is clear
   to me that it has value as a PAQ.  Silence = you don't care
</note>

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7999699
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to JonFish85

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 

Expert Comment

by:SpideyMod
ID: 8067891
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

803 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