HTML and CSS Reference
In-Depth Information
< body >
< header > < a href = ”#” onClick = ”someOtherWindow()” > Click to Open New Window </ a > </
header >
</ body >
</ html >
h is page requires a second page to open as a separate window. h e following ( OtherWindow.
html in this chapter's folder at www.wiley.com/go/smashinghtml5 ) provides a page to
open and, at the same time, the DOM-based script to close the open window.
<! DOCTYPE HTML >
< html >
< head >
< style type = ”text/css” >
h1 , h4 {
font - family : Verdana , Geneva , sans - serif ;
color : #930;
}
a {
text - decoration : none ;
color : #cc0000;
text - align : center ;
}
</ style >
< script type = ”text/javascript” >
function shutItDown ()
{
window . close ();
}
</script>
< meta http - equiv = ”Content-Type” content = ”text/html; charset=UTF-8” >
< title > Other Window </ title >
</ head >
< body >
< h1 > This window has an important message . . . .</ h1 >
< h4 > Stand by while I figure out what it is . . . .</ h4 >
< a href = ”#” onClick = ”shutItDown()” > Shut the window !</ a >
</ body >
</ html >
241
Figure 12-2 shows what you can expect to see when the Web page opens as second window.
Up to this point in the topic, when one page has linked to another page, the current page has
disappeared as soon as the user clicks a link. However, with this little JavaScript, you can
“talk” directly to the page and tell it you want a new window of a specii ed size to open while
your current window stays open.
 
Search WWH ::




Custom Search