Open In App

Web API URL.password Property

Last Updated : 12 Jul, 2022
Comments
Improve
Suggest changes
Like Article
Like
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(
'https://password:[email protected]/href#ExampleHash');
            
            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(
'https://password:[email protected]/href#ExampleHash');

            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

Next Article

Similar Reads