- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Anchor pathname Property
The HTML DOM Anchor pathname property is used to set or return the path name of the href attribute.
Following is the syntax to set the pathname property −
anchorObj.pathname = path
Above, path is the pathname of the URL.
Following is the syntax to return the pathname property −
anchorObj.pathname
Let us now see an example to implement the DOM Anchor pathname property −
Example
<!DOCTYPE html> <html> <body> <h1>Company</h1> <p><a id="mylink" hreflang="en" href="https −//abc.com/abc.html/#new">Products</a></p> <h2 id="myid"></h2> <button onclick="display1()">Display pathname</button> <button onclick="display2()">Display hreflang</button> <script> function display1() { var a = document.getElementById("mylink").pathname; document.getElementById("myid").innerHTML = a; } function display2() { var a = document.getElementById("mylink").hreflang; document.getElementById("myid").innerHTML = a; } </script> </body> </html>
Output
Above, click on “Display pathname” to display the path part −
- Related Articles
- HTML DOM Location pathname Property
- HTML DOM Anchor hostname Property
- HTML DOM Anchor protocol Property
- HTML DOM Anchor password Property
- HTML DOM Anchor href Property
- HTML DOM Anchor origin Property
- HTML DOM Anchor port Property
- HTML DOM Anchor hreflang Property
- HTML DOM Anchor download Property
- HTML DOM Anchor hash Property
- HTML DOM Anchor rel Property
- HTML DOM Anchor search Property
- HTML DOM Anchor target Property
- HTML DOM Anchor text Property
- HTML DOM Anchor type Property

Advertisements