The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Are you sure you want to navigate away from this page

4 posters

Go down

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

Post by xrisinkaa July 5th 2012, 1:18 am

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)
avatar
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 July 5th 2012, 1:45 am

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

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

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

Post by xrisinkaa July 5th 2012, 1:58 am

Can u give me the code pls and instructions how to put this code Smile
avatar
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 July 5th 2012, 11:07 pm

Its not working Sad
avatar
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 July 5th 2012, 11:20 pm

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);
LGforum
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

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

Post by xrisinkaa July 5th 2012, 11:22 pm

Nope.. its not working Sad
avatar
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 July 5th 2012, 11:35 pm

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.
LGforum
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

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

Post by xrisinkaa July 6th 2012, 1:06 am

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
avatar
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 July 6th 2012, 4:03 pm

its not working arww :@@@
avatar
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* July 6th 2012, 5:47 pm

And do you tick "In all pages"?
Proxy*64*
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 July 7th 2012, 12:42 am

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
avatar
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 July 7th 2012, 6:46 am

Topic Solved & Locked
Sanket
Sanket
ForumGuru

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

Back to top Go down

Back to top

- Similar topics

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