JavaScript HTML DOM ने HTML डेटा को एक्सेस और मैनिपुलेट करने के लिए कुछ बुनियादी मेथड्स प्रदान किए हैं। डॉक्यूमेंट का शीर्षक और URL खोजने के लिए, JavaScript ने क्रमशः document.title और document.URL प्रदान किए हैं। आइए उन्हें व्यक्तिगत रूप से चर्चा करें।
डॉक्यूमेंट का शीर्षक
डॉक्यूमेंट का शीर्षक प्राप्त करने के लिए JavaScript HTML DOM ने document.title मेथड प्रदान किया है।
निम्न उदाहरण में, डॉक्यूमेंट का शीर्षक ज्ञात किया गया है और आउटपुट में दिखाए अनुसार प्रदर्शित किया गया है।
उदाहरण
<html> <head> <title>Tutorix</title> </head> <body> <script> document.write("The title of the document is" + " " + document.title); </script> </body> </html>
आउटपुट
Tutorix
डॉक्यूमेंट का URL
डॉक्यूमेंट का URL प्राप्त करने के लिए JavaScript HTML DOM ने document.URL मेथड प्रदान किया है।
निम्न उदाहरण में, डॉक्यूमेंट का URL ज्ञात किया गया है और आउटपुट में प्रदर्शित किया गया है।
उदाहरण
<html> <body> <script> document.write("The URL of the document is:" + " " + document.URL) </script> </body> </html>
आउटपुट
The URL of the document is: https://www.tutorialspoint.com/cg/assets/ovPEzF.php