Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have written a script that restrict users to stick to current window. If they lose focus for 3 times, your current page gets redirected to blank page.

Problem here is, it works fine with Mozilla and chrome, but while clicking anywhere within the window frame in IE, it gives me alert window which is not expected behavior.
Can anybody please explain me why?
Thank You.

Here is my script:

HTML
<script type="text/javascript">

JavaScript
$(function () {
            var count = 0;
            window.onfocus = function (event) {
            }
            window.onblur = function (event) {
                increase(count);
                if (count == 2) {
                    alert("Switching between views is not allowed");
                }
                else if (count == 3) {
                    alert("This window will be closed as you made maximum                                                                                     attempts");
                    var win = window.open(("about:blank", "_self");
                    //win.close();
                   }
            }
            function increase() {
                count++;
                return false;
            }
            
        });

HTML
</script>
Posted
Updated 23-Jul-12 20:45pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900