Javascript Back Button - Stop back from closing window

Posted by Evan on Stack Overflow See other posts from Stack Overflow or by Evan
Published on 2010-05-30T12:56:40Z Indexed on 2010/05/30 13:02 UTC
Read the original article Hit count: 710

Filed under:
|
|
|
|

How do I get the "back" button seen in my demo to NOT close the browser window?

If this can't be prevented, then at least provide them with a confirmation box alerting them the window is trying to close and ask them if they want to continue.

I'm using a javascript back button link and forward button link to control the user's history inside a modal/lightbox window.

Here's a demo of what is happening... When you begin, the second page will have a link to the modal window, so click that, then click the "back" button in the window as it will take you BACK to the start page. That's the issue I'm having as I don't want this to happen.

http://www.apus.edu/_test/evan/modal/start.htm

<a href="javascript:history.go(-1)">Back Button</a> 
<a href="javascript:history.go(1)">Foward Button</a>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about button