473,320 Members | 2,052 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,320 software developers and data experts.

Diable the "Browser Back Button" and send user history back only through my "Back but

Hi,
My requirment is diable the "Browser Back Button" and create "Back Button" to go History -1.
Actually I want to send user history back only through my "Back button".

I could disable "Browser Back Button"

Expand|Select|Wrap|Line Numbers
  1. <script language="javaScript">
  2. function noBack() {
  3.     window.history.forward();
  4.  
  5.  window.onunload = function() {
  6.     null;
  7. };
  8. setTimeout("noBack()", 0);    
  9. }
  10. </script>
  11. <body onload="noBack();" >

And I could send user history -1 through bellow function.

Expand|Select|Wrap|Line Numbers
  1. <script language="javaScript">
  2. function goBack()
  3.  {
  4.       window.history.go(-1);
  5. }
  6. </script>
  7. <input type="button" onclick="goBack()" value="Go Back" />

My Problem is function goBack() will be disable because of function noBack().
Now I need to run function goBack() and stop noBack() when I click the button.

So I write condition like bellow. It doesn't work.


Expand|Select|Wrap|Line Numbers
  1. <script language="javaScript">
  2. //THIS IS BROWSER HISTORY BACK BLOCK - working fine
  3. var allowBack = false;
  4. function noBack() {
  5.     window.history.forward();
  6.  
  7.  window.onunload = function() {
  8.     null;
  9. };
  10. setTimeout("noBack()", 0);    
  11. }
  12.  
  13. // GO BACK BUTTON FUNCTION
  14. function goBack()
  15.  {
  16.     checkBack2();
  17.     noBack() == false;
  18.     allowBack = true;
  19.       window.history.go(-1);
  20.     return false;
  21. }
  22.  
  23. //BODY ONLOAD CHECK THE FUNCTION WHETHER GO BACK OR STAY THE PAGE
  24. function checkBack2(){
  25.     if(allowBack)
  26.     {
  27.         return goBack();
  28.     }
  29.     else
  30.     {
  31.         return noBack();
  32.     }
  33. }
  34. onclick="return goBack()"
  35. </script>
  36.  
  37. <body onload="checkBack2();" >

Note: We need 2 html files with same javascript to check the function.
So herewith I have attached tow .html files.
Attached Files
File Type: zip back_button.zip (1.5 KB, 94 views)
Jan 8 '14 #1
1 1976
Dormilich
8,658 Expert Mod 8TB
Actually I want to send user history back only through my "Back button".
why?

the back button works perfectly in all browsers.

PS. if my back button were blocked by a webpage script, I’d be sure no not come back.
Jan 8 '14 #2

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

Similar topics

3
by: riotctrl | last post by:
Is there a way to use the history.back to display the actual url of the last page to the page ?
1
by: Justin | last post by:
Hi, I have a simple frameset defined: ---------------- index.html ---------------- <FRAMESET COLS = "225,*"> <FRAME NAME = "a" SRC = "one.html"> <FRAME NAME = "b" SRC = "one.html">...
4
by: Ike | last post by:
Can someone show me how I can have: <a href="javascript:history.back()" name="Back" value="Back" style=width:40px;float:right;margin-left:0px class="button" >Back</a> but since this href...
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 { }
3
by: Alan | last post by:
I have a form that contains many fields for the user to enter. After entering the data the user can click a link to open a new window, the new window contains six columns (pull down menu) and 30...
3
by: Olaf Rabbachin | last post by:
Hi *, ich erzeuge zur Laufzeit in einer ASP-Tabelle Tabellenzellen. Im Großteil dieser Zellen befinden sich Checkboxes. Per JS ändere ich beim Click auf eine solche Zelle oder deren Checkbox die...
2
by: Otto Wyss | last post by:
On a page of mine a user might submit data several time, which adds an entry to the history each time (similar as http://www.google.com/trends?q=iPod%2C+iPhone&ctab=0&geo=all&date=all). Yet later...
7
by: mohammed.naghman | last post by:
Hi, I have 2 submit buttons in a jsp page. One of them takes me to page2.jsp and also passes the values enetered to page2.I have a link in the page2 that does a history.back to come to the...
1
Gyanchand
by: Gyanchand | last post by:
I wouldn't want the user to use the History.Back option in a page by presssing backspace or on the popup menu.....back.. is there any method by whcih i can prevent the user from using history.back
2
by: Max | last post by:
I recently moved to ASPnet Ext 3.5 What I can't get with Ajax and History browser managemet is this: User fills some fields (dropdown and textbox) on page 1 (all are in an update panel) User...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.