HTML विंडो शीर्ष गुण वर्तमान विंडो की सबसे ऊपरी ब्राउज़र विंडो लौटाता है।
सिंटैक्स
निम्नलिखित वाक्य रचना है -
window.top
आइए HTML विंडो टॉप प्रॉपर्टी का एक उदाहरण देखें -
उदाहरण
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #8BC6EC;
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%) no-repeat;
text-align: center;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 30%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem auto;
}
.show{
font-size:1.2rem;
}
</style>
<body>
<h1>HTML Window top Property Demo</h1>
<button onclick="create()" class="btn">Check current window is topmost</button>
<div class="show"></div>
<script>
function create(){
if(window.top === window.self){
document.querySelector('.show').innerHTML='The current window is the topmost window';
} else{
document.querySelector('.show').innerHTML='The current window is not the topmost window';
}
}
</script>
</body>
</html> आउटपुट

“जांच करें कि वर्तमान विंडो सबसे ऊपर है . पर क्लिक करें " बटन यह जांचने के लिए कि वर्तमान विंडो सबसे ऊपरी विंडो है या नहीं:
