rewdy/leaveNotice

I want it to still open in a new window

Closed this issue · 1 comments

Is it possible to still open the link in a new window? That is, I want to show the dialog but still want it to open in a new (_blank) window. Is this possible?

Hello Rami,

The short answer to your question, is that you can sort of force the plugin to open links in a new window, but it's not easy as the script wasn't really designed to work that way.

One of the primary reasons I wrote it was because in some usability testing I found a lot of users were confused by windows opening when they click links because when the new window opened the back button didn't take them back any longer (they had to close the window instead). The goal of the script was to notify the user they are leaving, but otherwise keep the back button behavior in tact.

If you want to force the links to open in a new window, there are two things you can do.

  1. there is a linkString option when you initiate the plugin. This string gets added to the link in the leaveNotice modal. You can add 'target="_blank"' to the links using that option. This will make it so if the user clicks the link from the modal it opens in a new window.
  2. The default functionality of the plugin automatically redirects to the page after a timeout period. You can turn this off by setting the option timeOut to 0, in which case the user will have to click the link to continue.

If you want it to automatically follow the link in a new window, you would actually have to edit the leaveNotice script and use a modified version. If you want to do this, you can edit line 85 (of the uncompressed code) to do something like window.open(url,'new_window') instead of what it is currently doing window.location.href(url);.

If you go with the option to edit the plugin script, be advised that a lot of browsers block the window.open() command because it is often abused by sketchy websites.

Hopefully that information is helpful for you. Good luck.