X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Anchor username Property

Anchor Object Reference Anchor Object

Example

Return the username part of a link:

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

The result of x will be:

johnsmith

Try it yourself »


Definition and Usage

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

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

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

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


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

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

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


Syntax

Return the username property:

anchorObject.username

Set the username property:

anchorObject.username=username

Property Values

Value Description
username Specifies the username part of a URL

Technical Details

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


More Examples

Example

Change the username part of a link:

document.getElementById("myAnchor").username = "newUsername";

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

SHARE THIS PAGE

facebook