<
html
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=gb2312"
/>
<
title
>index
</title>
</head>
<
body
>
<
div
id
="container"
>
<
iframe
src
="left.htm"
name
="leftFrame"
width
="20%"
height
="100%"
align
="middle"
scrolling
="no"
/>
<
iframe
src
="right.html"
id
="platformFrame"
name
="platformFrame"
width
="80%"
height
="100%"
align
="middle"
scrolling
="auto"
/>
</div>
</body>
</html>
<
html
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=gb2312"
/>
<
title
>index
</title>
</head>
<
body
>
left
</body>
</html>
Right.html:
<
html
>
<
head
>
</head>
<
body
>
right
</body>
<
script
type
="text/javascript"
language
="javascript"
>
<
!
--window.top:最頂層窗口 window.self:當前窗口 --
>
if (window.top!=window.self)
{
window.top.location='right.html'
}
</script>
</html>
以上最主要的就是就是這段JavaScript:
if (window.top!=window.self)
{
window.top.location='right.html'
}
它的意思就是當right.html不爲頂層窗口時將它設置爲頂層窗口。
當right.html沒有這段js時點擊index.html頁面,將以下顯示:
當right.html有這段js時點擊index.html頁面,將以下顯示: