Are you sure you want to navigate away from this page

Go down

Solved Are you sure you want to navigate away from this page

Post by xrisinkaa on Wed 4 Jul - 19:18

I have a web page - www.all-serials.net that contains a textbox and a submit button. When the user edits the text in the textbox and clicks another link (not the submit button) how do I display the 'Are you sure you want to navigate away from this page' popup message? I want some code or IDK.. My version is PunBB (punbb)

xrisinkaa
Forumember

Female Posts : 139
Reputation : 0
Language : bulgarian

http://www.all-serials.net/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by LGforum on Wed 4 Jul - 19:45

You would use the window.onunload event by attaching an event handler. The handler would ask the user if they wish to leave.
avatar
LGforum
Hyperactive

Male Posts : 2263
Reputation : 260
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by xrisinkaa on Wed 4 Jul - 19:58

Can u give me the code pls and instructions how to put this code Smile

xrisinkaa
Forumember

Female Posts : 139
Reputation : 0
Language : bulgarian

http://www.all-serials.net/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by xrisinkaa on Thu 5 Jul - 17:07

Its not working Sad

xrisinkaa
Forumember

Female Posts : 139
Reputation : 0
Language : bulgarian

http://www.all-serials.net/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by LGforum on Thu 5 Jul - 17:20

Try this:
Code:

(function(b){
  var f = function() { return confirm('Are you sure you wish to leave?'); };
  if(b.attachEvent) {
    b.attachEvent('onunload', f);
  }
  else {
    b.addEventListener('unload', f, false);
  }
})(document.body);
avatar
LGforum
Hyperactive

Male Posts : 2263
Reputation : 260
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by xrisinkaa on Thu 5 Jul - 17:22

Nope.. its not working Sad

xrisinkaa
Forumember

Female Posts : 139
Reputation : 0
Language : bulgarian

http://www.all-serials.net/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by LGforum on Thu 5 Jul - 17:35

I'm not sure if unload event is fired when clicking links to a new page. Only clicking back/forward and closing or reloading the page.

Might have to think of an alternative way.
avatar
LGforum
Hyperactive

Male Posts : 2263
Reputation : 260
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by xrisinkaa on Thu 5 Jul - 19:06

I post ur code in java.. click in 1 topic, write something in quick reply and then click F5 to refresh the page.. and nothing.. i lost my message

xrisinkaa
Forumember

Female Posts : 139
Reputation : 0
Language : bulgarian

http://www.all-serials.net/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by xrisinkaa on Fri 6 Jul - 10:03

its not working arww :@@@

xrisinkaa
Forumember

Female Posts : 139
Reputation : 0
Language : bulgarian

http://www.all-serials.net/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by Proxy*64* on Fri 6 Jul - 11:47

And do you tick "In all pages"?
avatar
Proxy*64*
Forumember

Male Posts : 113
Reputation : 6
Language : English,Greek|HTML/CSS/jQuery

http://fataola.forumgreek.com

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by xrisinkaa on Fri 6 Jul - 18:42

Yes java is turning on and tick to all pages, but now its working the other admin put the link in css i think idk.. and now its working.. thanks for codes Smile

xrisinkaa
Forumember

Female Posts : 139
Reputation : 0
Language : bulgarian

http://www.all-serials.net/

Back to top Go down

Solved Re: Are you sure you want to navigate away from this page

Post by Sanket on Sat 7 Jul - 0:46

Topic Solved & Locked
avatar
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2828
Language : English
Location : Mumbai

http://webartzforum.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum