Welcome Guest, Not a member yet? Register   Sign In
Verify before page refresh or back - is there a way?
#1

[eluser]Barwick[/eluser]
Question - is there a way to verify (via pop-up or some other method) before a user's back to page refresh or hit the browser back button?

For example, if I'm on a page and I go to hit the 'back' button or do a browser page refresh, before I'm able too I'll need to verify (via a pop-up) that I actually want to leave the page...

Not idea where to start with this. Scripts/code/examples anyone? I realize this might not be a Codeigniter related question. Or maybe it is...

Cheers,
Mike
#2

[eluser]Aken[/eluser]
You'd need to use Javascript. Curious why you want to do it, though? I would typically advise against using them, because they're annoying.
#3

[eluser]Barwick[/eluser]
Typically, I would agree 100%. But this would only be used on a wizard-campaign builder type of thing - which the entire page is all Ajax. Just testing the application I've hit the back button myself a couple times by mistake lol. So an "Are you sure you want to exit?" message or pop-up is a good way to remind/prevent. My thoughts anyways...
#4

[eluser]solid9[/eluser]
Yes JavaScript is the way to this.
You need to repost your question again on JavaSript forums.
#5

[eluser]Mirge[/eluser]
Heh, no need to repost on a different forum -- it's very simple. You want to bind to the "onbeforeunload" event. Here's a SO question that's been answered that explains it in greater detail:

http://stackoverflow.com/questions/12994...away-in-js
#6

[eluser]solid9[/eluser]
@mirge

yeah I forgot Google is our best friend. ^__^




Theme © iAndrew 2016 - Forum software by © MyBB