जावास्क्रिप्ट दस्तावेज़.href . प्रदान किया है और दस्तावेज़.लक्ष्य एक लिंक में href और लक्ष्य विशेषताएँ प्राप्त करने के लिए। एक लिंक आमतौर पर
href विशेषता ढूँढना
Href विशेषता प्राप्त करने के लिए, document.href उपयोग किया जाना चाहिए। निम्नलिखित उदाहरण में, href विशेषता में "http://www.tutorialspoint.com/" नामक एक लिंक होता है, जिसे प्रोग्राम के निष्पादित होने के बाद प्रदर्शित किया जाएगा।
उदाहरण
<html>
<body>
<p><a id="myId" href="http://www.tutorialspoint.com/">tutorialspoint</a></p>
<script>
var ref = document.getElementById("myId").href;
document.write(ref);
</script>
</body>
</html> आउटपुट
tutorialspoint http://www.tutorialspoint.com/
लक्ष्य विशेषता ढूँढना
लक्ष्य प्राप्त करने के लिए विशेषता, दस्तावेज़.लक्ष्य उपयोग किया जाना चाहिए। निम्नलिखित उदाहरण में, लक्ष्य विशेषता "_union " कार्यक्रम के निष्पादित होने पर प्रदर्शित किया गया था।
उदाहरण
<html>
<body>
<p><a id="myId" target="_union" href="http://www.tutorialspoint.com/">tutorialspoint</a></p>
<script>
var ref = document.getElementById("myId").target;
document.write(ref);
</script>
</body>
</html> आउटपुट
tutorialspoint _union