Skip to content
Related Articles
Open in App
Not now

Related Articles

Web API URL.password Property

Improve Article
Save Article
  • Last Updated : 12 Jul, 2022
Improve Article
Save Article

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!