Annoy Users with onBlur in Javascript
<body onBlur="self.focus();">
-We used Javascript's built-in onBlur event handler.
-We then called Javascript's built-in
focus method. (
self in this instance means "this window")
-We put all this in the HTML body tag.
NOTE: This would force a user to close the window before moving on so you could keep a user on your site forever and ever... actually, it has other uses, like
calling a function, etc. This was just an easy way to show how it works.
NOTE: onBlur can be used in many different places other than the
body tag, like a
textarea, text field, select menu, frame and
frameset.
NOTE: Safari for Mac will only bring the window back into focus once. You'll have to find a different way to annoy us :)
Free Copy and Paste Javascript Code:
<script type="text/javascript">
<!--
function yoyo() {
window.close();
}
-->
</script>
<body onBlur="yoyo()">
Resources:
Focus a Window with self.focus in Javascript
Create a Function in Javascript
Call your Function in Javascript
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | | |
| | | |
| | CSS David McFarland | |