views:

161

answers:

1

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>
A: 

If you can see where they are in the page (ie: the start page having a static back / forward button ) why not just make the back button a javascript:void(0)? If you aren't going to have a defined front location, use server side to store their start place, and once they have reached it, disable the back option.

Akidi
unfortunately, server side isn't possible. i'm looking for client side javascript to handle the work. the back/forward button would be at the template level, wouldn't be dynamic, can not be added to the page level.
Evan
Unfortunately javascript has severe restrictions on its actual manipulation of the back / forward options ( you aren't allowed much access to the window.history object ). With the restrictions in place there may not be a way to do what you need. Other than perhaps viewing the pageid you are on ( or equivalent ) and using that to determine if a back button should show
Akidi