1,105,363 Community Members

Pop Up Script Not Working On IE

Member Avatar
markyeoj
Newbie Poster
5 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi, Im not sure why this code is not working on IE browsers but on chrome its working well. This code is for a Popup, that will ask the users if stay or leave page once they try to refresh or go to other webpage. (you can test www.thesuperheroblueprint.com).. and what ever they choose, the should be redirected on a particular page.

<script type="text/javascript">
// Popup window code
function newPopup(url) {
    popupWindow = window.open(
        url,'popUpWindow','height=500,width=600,left=10,top=10,resizable=no,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no')
}
</script>
</div>
<!---Exit Pop-->
<script language="javascript">
(function() {
    setTimeout(function() {
    var __redirect_to = 'http://thesuperheroblueprint.com/exit.html';//

    var _tags = ['button', 'input', 'a'], _els, _i, _i2;
    for(_i in _tags) {
        _els = document.getElementsByTagName(_tags[_i]);
        for(_i2 in _els) {
            if((_tags[_i] == 'input' && _els[_i2].type != 'button' && _els[_i2].type != 'submit' && _els[_i2].type != 'image') || _els[_i2].target == '_blank') continue;
            _els[_i2].onclick = function() {window.onbeforeunload = function(){};}
        }
   }

    window.onbeforeunload = function() {
        setTimeout(function() {
            window.onbeforeunload = function() {};
            setTimeout(function() {
                document.location.href = __redirect_to;
            }, 500);
        },5);
        return 'WAIT BEFORE YOU GO! CLICK THE *CANCEL* BUTTON RIGHT NOW! PAGE. I HAVE SOMETHING VERY SPECIAL FOR YOU COMPLETELY FREE.';
    }
    }, 500);
})();
</script>
<!--End Exit Pop-->

Hope you can give me a hint or help to fix this. Thank You

Member Avatar
gon1387
Posting Whiz in Training
242 posts since Jan 2011
Reputation Points: 22 [?]
Q&As Helped to Solve: 38 [?]
Skill Endorsements: 4 [?]
 
0
 

I found no errors in the script, nor any culprit in the script for it not to run; even problems with older IE versions.
My guess here is, maybe there is/are extentions in your IE that perturbs its execution; or misconfigurations.

Member Avatar
stbuchok
Posting Shark
957 posts since May 2011
Reputation Points: 123 [?]
Q&As Helped to Solve: 142 [?]
Skill Endorsements: 2 [?]
 
0
 

Honestly, I would remove this altogether. I know you want help with the script, but think about your users first and foremost. If I went to your site and it asked me if "Are you sure you really want to leave", I would click yes and never come back. Ask people how annoying they find this, actually, ask yourself how annoying you find this on other sites.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: