Properti jendela atas
Definisi dan Penggunaan
Top properti mengembalikan window paling atas jendela browser saat ini.
tatabahasa
window.top
Dukungan Browser
Semua browser utama mendukung properti atas
contoh
contoh
Ketika klik "Lihat jendela" tombol, periksa () dipanggil, dan memeriksa keadaan saat jendela:
<!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>
Coba »
objek jendela