At times, you will want to make a page active or re-gain focus after it has been loaded. You probably have seen a lot of these already while surfing the internet, especially from sites that has a lot of pop up ads.
One simple line of Javascript code window.focus(); will make the loading window gain focus. Alternatively, you might want to wait for the window to completely finish loading before you making it gain focus. To do so, simply add window.focus(); in the tag of the document along with the onload event.
Here's the code:
<HTML>
<Body onload="window.focus();">
</HTML>
Another way is to put the script at the very last line of code, just before tag as seen in the code below:
<HTML>
<Body>
...
...
<script language=javascript>
window.focus();
</script>
</Body>
</HTML>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment