1

I need a help in exist Pop Blocker which block closing a site and it should Not block any internal webpage function.

Example site URL : http://beyondhosting.net/Dedicated-Cloud-Servers/Managed-Servers/ (I need same as this URL Exist Pop contain)

It only Block on close, Not in refresh, going to different link and Internal webpage functions.

Can anyone please help me with Exist Pop blocker code which Block only on Tab or window close.

Currently i am trying

<script>
a = document.getElementById('audio');

a.onended = function(){setTimeout("a.play()", 1000)}
</script>

    <script type="text/javascript">
      var hook = true;
      window.onbeforeunload = function() {
        if (hook) {
          return "Did you save your stuff?"
        }
      }
      function unhook() {
        hook=false;
      }
    </script>
<div Onclick"Unhook"></div>

But it not performing well, It blocking another internal link, external link and even refresh, But i need it should only block on exist or closing tab or window and it should allow everything. I have provide Example URL which are using the script like i want, But i unable to find it.

Thanks in advance.

  • You cannot differentiate if beforeunload is fired because of closing/refreshing or redirecting. On this site, they probably use some hacky way but could became easily inconsistent. For example to avoid beforeunload on clicking anchor: http://stackoverflow.com/a/18824483/1414562 To get selector for internal links only: https://css-tricks.com/snippets/jquery/find-all-internal-links/ Now regarding the close or refresh distinction. See http://stackoverflow.com/a/24017120/1414562 – A. Wolff Jan 23 '16 at 16:06
  • Still facing same issues. Atleast can you tell me How i can add Unhook for DIV whole sections, if any click under that div will not block by exist popup. It is working `` but this not working `
    `
    – Rajeev Ranjan Sharma Jan 23 '16 at 17:17

0 Answers0