Solved

How do I know if user has hit BACK button ?

Posted on 2001-07-12
6
296 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

758 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

18 Experts available now in Live!

Get 1:1 Help Now