- 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 URL Property
The HTML DOM URL property returns a string corresponding to the url of the document.
Following is the syntax −
Returning string value
document.URL
Let us see an example of HTML DOM URL property −
Example
<!DOCTYPE html> <html> <head> <title>HTML DOM URL</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>HTML-DOM-URL</legend> <h2 >This is a Demo Example</h2> <input type="button" value="Get Link" onclick="getLink()"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); function getLink() { divDisplay.textContent = document.URL; } </script> </body> </html>
Output
Before clicking ‘Get Link’ button −
After clicking ‘Get Link’ button −
Advertisements