We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,453 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Pop Up Script Not Working On IE

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

3
Contributors
2
Replies
1 Hour
Discussion Span
4 Months Ago
Last Updated
3
Views
markyeoj
Newbie Poster
2 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

gon1387
Posting Whiz in Training
233 posts since Jan 2011
Reputation Points: 32
Solved Threads: 37
Skill Endorsements: 3

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.

stbuchok
Practically a Posting Shark
876 posts since May 2011
Reputation Points: 138
Solved Threads: 124
Skill Endorsements: 2

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.2939 seconds using 2.71MB