HTML and CSS Reference
In-Depth Information
Figure 13.6 When focus is on the left frame, it turns pink. When focus leaves the left
frame, it turns yellow. Notice the mouse pointer is in the right frame. That's where
the focus is. Check the status bar.
The focus() and blur() Methods. The focus() and blur() methods behave exactly
the same as their like-named events. These methods are applied to an object, such as a
window or form object, and are called from the JavaScript program. When the focus()
method is applied to an object, it will cause that object to be in focus and when the blur()
method is applied to an object, it will lose its input focus.
EXAMPLE 13.7
<html>
<head><title>The focus and blur methods</title>
<script type="text/javascript">
1
function newWindow(){
2
winObj=window.open ("summertime.jpg",
"summer","width=650,height=200,resizable=yes,
scrollbars=yes,location=yes");
3
winObj.moveTo(0,0); // Move to left corner of screen
4
winObj.focus();
// New window gets the focus
//windObj.blur();
}
5
function closeWindow(){
6
winObj.close();
// Close the new window
}
</script>
</head>
<body bgColor="lightgreen">
<h2>Summer Scene from the Old Country</h2>
<form>
<input type=button
value="Open Window"
7
onClick="JavaScript:newWindow();" />
<input type=button
value="Close Window"
8
onClick="JavaScript:closeWindow();" />
 
Search WWH ::




Custom Search