Reputation: 5166
I came up with a problem that my website users are cheating on online games . For the cheating part they need to do some part of the flash games and then switch the window and use their desktop applications to cheat and change the records
Now , I think if I find a way to stop users from switching windows while they are playing I can stop these cheats.
I used this function on jquery but It didn't work.
$(window).focus(); or $(document).focus();
when the window focus is out I need to alert the user and then refresh the page
I saw something like this in Comet Chat script when the focus is out and the window is changed there was a function to recall sounds (dings)
Is there anything compatible with Jquery to handle window focus ?
Upvotes: 0
Views: 848
Reputation: 13821
There is no reliable way to highjack the user's screen. If there were, spam sites would hold us all hostage. The website markup does not have as much control over the client as you might think. Always assume that the user has more power over his/her desktop than you do.
Even if you could accomplish your goal, the users could still cheat by connecting using a program other than a web browser. Enforcing your "security" (or cheat prevention) solely client side is nearly always a bad idea. You need to find a way to make your fix server side, where the user has no control.
Upvotes: 1
Reputation: 3125
Try this:
$(window).blur(function() {
// naughty naughty handling code
});
Upvotes: 0
Reputation: 146360
Well .focus()
is usually just for input elements.
You could try some combination of click
and mouseover
Upvotes: 0