창 상단의 속성
정의 및 사용
Top 속성은 현재 창 맨 위의 브라우저 창을 반환합니다.
문법
window.top
브라우저 지원
모든 주요 브라우저 상단 속성을 지원
예
예
클릭 버튼 "창을 확인"할 때, () 검사라고하며, 윈도우의 현재 상태를 확인하십시오
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function check(){
if (window.top!=window.self) {
document.write("<p>这个窗口不是最顶层窗口!我在一个框架?</p>")
}
else{
document.write("<p>这个窗口是最顶层窗口!</p>")
}
}
</script>
</head>
<body>
<input type="button" onclick="check()" value="检查窗口">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function check(){
if (window.top!=window.self) {
document.write("<p>这个窗口不是最顶层窗口!我在一个框架?</p>")
}
else{
document.write("<p>这个窗口是最顶层窗口!</p>")
}
}
</script>
</head>
<body>
<input type="button" onclick="check()" value="检查窗口">
</body>
</html>
»시도
Window 객체