I have a page-a where I offer something for $10 , when the user tries to leave the page, I would like to ask them if they want same thing for $5.
So using onunload I could show a confirmation box with my message using this code.
function goodbye(e) {
if(!e) e = window.event;
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = 'Hey Wait, Get everything mentioned below for $5, Click on Stay on this page?'; //This is displayed on the dialog
//e.stopPropagation works in Firefox.
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
}
window.onbeforeunload=goodbye;
Now when the user clicks on Stay on this page, I want the page to redirect to page-b where same thing is available for $5.
Can anyone help me where do I have to write extra lines of codes ? I did quick research but could not find any help.
Thank you in advance.