Open In App

Web API URL.password Property

Last Updated : 12 Jul, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The Web API URL.password property returns a USVString containing the password specified before the domain name of the URL. A USVString is a sequence of Unicode scalar values.

Syntax:

var str = URL.password

Return Value: This property returns a USVString containing the password specified before the domain name of the URL.

Example 1:

HTML




<!DOCTYPE html>
<html>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <button onclick="get()" x='15' y='30'>
        Click on Me!
    </button>
 
    <script type="text/javascript">
        function get() {
            var url = new URL(
             
            console.log("password of current URL is :",
                url.password);
        }
    </script>
</body>
 
</html>


Output:

Example 2:

HTML




<!DOCTYPE html>
<html>
 
<body>
    <h1>GeeksforGeeks</h1>
 
    <div id="abc"></div>
 
    <button onclick="get()" x='15' y='30'>
        Click on Me!
    </button>
 
    <script type="text/javascript">
        function get() {
            var url = new URL(
 
            a = document.getElementById("abc");
            a.innerHTML = "password of current URL is : "
                + url.password;
        }
    </script>
</body>
 
</html>


Output:

Supported Browsers:

  • Safari 10
  • Opera 19
  • Chrome 32
  • Edge 12
  • Firefox 26


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads