Hi,

In your code no one sets dont_confirm_leave to 1.


On Mon, Apr 22, 2013 at 10:51 PM, Anna Simbirtsev <[email protected]>wrote:

> We try to use the following java script to detect window close or redirect
> event. We are trying to ignore the submit button, but it does not work.
>
> <div class="submitarea"><a
> class="button submitarea" onclick="var
> e=document.getElementById('myForm8_hf_0'); e.name='submitButton';
> e.value='x';var f=document.getElementById('myForm8');var ff=f;if
> (ff.onsubmit != undefined) { if (ff.onsubmit()==false) return false;
> }f.submit();e.value='';e.name='';return
> false;" wicket:id="submitButton" href="#">SUBMIT</a></div>"
>
>
> function wireUpEvents() {
>
> var dont_confirm_leave = 0; //set dont_confirm_leave to 1 when you want the
> user to be able to leave withou confirmation
> var leave_message = 'You sure you want to leave?'
> function goodbye(e) {
> if (!validNavigation) {
> if (dont_confirm_leave!==1) {
> if(!e) e = window.event;
> //e.cancelBubble is supported by IE - this will kill the bubbling process.
> e.cancelBubble = true;
> e.returnValue = leave_message;
> //e.stopPropagation works in Firefox.
> if (e.stopPropagation) {
> e.stopPropagation();
> e.preventDefault();
> }
> //return works for Chrome and Safari
> return leave_message;
> }
> }
> }
> window.onbeforeunload=goodbye;
>
> // Attach the event keypress to exclude the F5 refresh
> $(document).bind('keypress', function(e) {
> if (e.keyCode == 116){
> validNavigation = true;
> }
> });
>
> // Attach the event click for all links in the page
> $("a").bind("click", function() {
> validNavigation = true;
> });
>
> $("a").live("click", function() {
> validNavigation = true;
> });
> // Attach the event submit for all forms in the page
> $("form").bind("submit", function() {
> validNavigation = true;
> });
>
> // Attach the event click for all inputs in the page
> $("input[type=submit]").bind("click", function() {
> validNavigation = true;
> });
>
> }
>
> // Wire up the events as soon as the DOM tree is ready
> $(document).ready(function() {
> wireUpEvents();
> });
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Reply via email to