इस उदाहरण में, आप एक जावास्क्रिप्ट प्रोग्राम लिखना सीखेंगे जो वर्तमान URL प्राप्त करेगा।
उदाहरण: वर्तमान URL प्राप्त करें
// program to get the URL const url1 = window.location.href; const url2 = document.URL; console.log(url1); console.log(url2);
आउटपुट
https://www.google.com/ https://www.google.com/
उपरोक्त कार्यक्रम में, window.location.hrefसंपत्ति और document.URLसंपत्ति का उपयोग वर्तमान पृष्ठ का URL प्राप्त करने के लिए किया जाता है।
दोनों window.location.hrefऔर document.URLगुण वर्तमान पृष्ठ का URL लौटाते हैं।








