Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Able to Bypass Prompt if Link Clicks Are Close Together #45

Closed
bsardo opened this issue May 30, 2014 · 2 comments
Closed

Able to Bypass Prompt if Link Clicks Are Close Together #45

bsardo opened this issue May 30, 2014 · 2 comments
Milestone

Comments

@bsardo
Copy link

bsardo commented May 30, 2014

Hey there!

I want to first say thanks for the plugin!

I started using this plugin at v1.6 and did not have any issues.

I just recently upgraded to v1.7 for the safari support but I noticed an issue in v1.7 that I cannot duplicate in v1.6.

With v1.7, if I make my form dirty and then repeatedly click a link on the page and answer 'stay on the page', I am eventually navigated away from the page without receiving the confirmation popup. This occurs if my link clicks and answers to the prompt to stay on the page are quick, approximately a second or two apart from each other.

To illustrate my point, consider the following sequence of events (note this is just an example, not the only sequence that results in the issue):

  1. make form dirty
  2. click link 1 @t=0
  3. answer prompt with 'stay on the page' @t ~= 1 sec
  4. click link 1 @t ~= 1 sec
  5. answer prompt with 'stay on the page' @t ~= 2 sec
  6. click link 1 @t ~= 2 sec
  7. no prompt received, navigated to link 1 target

The problem is not browser-specific; I was able to produce this issue using v1.7 in chrome, firefox, and IE.

Brian

@codedance
Copy link
Owner

Hi Brian,

Good find. This was one of the changes introduced into 1.7. Both IE and Chrome will raise multiple "beforeunload" events causing the popup to appear twice. To work around this, I used a timer (only show the message once in any given 1 second window) At the moment the timer is set for 1 second (1000 ms).

FYI - some discussion here: http://stackoverflow.com/questions/4126820/window-onbeforeunload-may-fire-multiple-times

There are a few options if people think this is an issue:

  1. The 1.6 behaviour could remain a default on Safari and Firefox. (i.e. Only use the timer method on browsers with known multiple event conditions).

  2. The timer could be shortened to minimise the window. (e.g. 500 should be enough for most situations.)

I'd welcome your thoughts? If

Cheers,

Chris

@codedance codedance added bug and removed question labels Jun 2, 2014
@codedance codedance added this to the 1.8 milestone Jun 2, 2014
@codedance
Copy link
Owner

I've made a few changes that should help mitigate this issue:

  • The timer test will only occur on browsers with known double onbeforeunload events (IE and Chrome)
  • I've dropped the timer down a bit from 1000ms to 900ms. I thank we could take this down even further but stick with this for the 1.8 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants