HTML and CSS Reference
In-Depth Information
Figure 10.28 When the user clicks a link in the left frame, the background color in
the right frame changes: Output from Example 10.17.
JavaScript code shown in Example 10.18 into the <head> portion of the page. Every win-
dow and frame has a top property, a reference to the topmost window object currently
loaded in the browser.
EXAMPLE 10.18
<html>
<head><title>Forcing the Frame</title>
<script type = "text/javascript">
1
if ( window != top ){ // True if window is not the top
// window in the hierarchy
2
top.location.href = location.href;
// Put this window on top
}
</script>
3
<body bgcolor="lightblue">
<h1>
The important page that we're talking about
</h1>
</body>
</html>
EXPLANATION
1
If the current window is not at the top of the window hierarchy in the browser,
the statement in the block is evaluated. The top property references the highest
object in the window hierarchy.
Continues
Search WWH ::




Custom Search