Solved

How do I know if user has hit BACK button ?

Posted on 2001-07-12
6
297 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now