Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

In a web page I have made a Tabbed Menu with three different pages .It works fine until user press the back button , this makes the control to move among these tabbed pages . I want to link a page to the back Button in browser . I have searched google most of people say it is not possible . I have tried using window.onbeforeunload but this also not works .Please help how to do this or any work around?

share|improve this question
1  
Where should the back button take you to ? –  harsha Aug 9 '13 at 6:16
    
Some example ? What you'd tried ? Or fiddle of the Tabbed Menu. –  M1K1O Aug 9 '13 at 6:16
1  
Set a cookie in the next page, check onload if cookie is set - clear the cookie and use location.replace(URL) to not break the back button –  mplungjan Aug 9 '13 at 6:18
3  
@fakerainbrigand - kidding right? –  mplungjan Aug 9 '13 at 6:19
1  
@mplungjan, nope! You can just use the history API to keep pushing a new item onto the history stack when the back button is pressed, and also handle it in some other way :-) –  FakeRainBrigand Aug 9 '13 at 6:20

1 Answer 1

you can to this by this method

onClick="history.go(-1);return true;

<input type="button" value="Back" onClick="history.go(-1);return true;">

or

<script>
function goBack()
  {
  window.history.back()
  }
</script>

<input type="button" value="Back" onclick="goBack()">
share|improve this answer
    
This is not what I meant!!! –  NAVdroid Aug 9 '13 at 6:22
    
as per your comment "To my peferable link.... like the last page!!" it will take you to the last page –  Roy Sonasish Aug 9 '13 at 6:23
    
No actually I want this method to be called at BROWSER's BACK BUTTON click(button on the left corner)!!!! –  NAVdroid Aug 9 '13 at 6:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.