Solved

How do I know if user has hit BACK button ?

Posted on 2001-07-12
6
301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

734 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