विंडो ऑब्जेक्ट में जावास्क्रिप्ट में स्थान ऑब्जेक्ट शामिल है। इसमें निम्नलिखित गुण शामिल हैं -
window.location.href
यह वर्तमान पृष्ठ का URL देता है।
उदाहरण
<!DOCTYPE html>
<html>
<body>
<p>Click below to get the complete URL of the page.</p>
<button onclick = "display()">URL</button>
<script>
function display() {
var res = location.href;
document.write(res);
}
</script>
</body>
</html> window.location.replace
इसका उपयोग वर्तमान दस्तावेज़ को बदलने के लिए किया जाता है।
उदाहरण
<!DOCTYPE html>
<html>
<body>
<button onclick = "display()">Replace current document</button>
<script>
function display() {
location.replace("https://www.qries.com")
}
</script>
</body>
</html> विंडो.स्थान.असाइन करें
यदि आप एक नया दस्तावेज़ लोड करना चाहते हैं, तो जावास्क्रिप्ट असाइन करें का उपयोग करें।
उदाहरण
<!DOCTYPE html>
<html>
<body>
<button onclick = "display()">Open new document</button>
<script>
function display() {
location.assign("https://www.qries.com")
}
</script>
</body>
</html>