X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Anchor password Property

Anchor Object Reference Anchor Object

Example

Return the password part of a link:

var x = document.getElementById("myAnchor").password;

The result of x will be:

smith123

Try it yourself »


Definition and Usage

The password property sets or returns the password part of the href attribute value.

In a URL, the password part is the password entered by the user. It is specified after the username and before the hostname.

Example: https://johnsmith:smith123@www.example.com (johnsmith is the username and smith123 is the password).

Tip: Use the username property to set or return the username part of the href attribute value.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The password property is supported in all major browsers, except Internet Explorer and Safari.

Note: The password property is not supported in Opera version 12 (and earlier).


Syntax

Return the password property:

anchorObject.password

Set the password property:

anchorObject.password=password

Property Values

Value Description
password Specifies the password part of a URL

Technical Details

Return Value: A String, representing the password part of the URL


More Examples

Example

Change the password part of a link:

document.getElementById("myAnchor").password = "newPassword101";

Try it yourself »


Anchor Object Reference Anchor Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook