Skip to content
Related Articles

Related Articles

Improve Article
Web API URL.password Property
  • Last Updated : 27 Nov, 2020

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
  • Opera
  • Chrome
  • Edge
  • Firefox



My Personal Notes arrow_drop_up
Recommended Articles
Page :