Area username attribute

Definition and usage

username Attribute set or return href attribute value The username part.

href The attribute specifies the destination of the link in the specified area.

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

For example: https://billgates:bill234@www.example.com (billgates is the username, bill234 is the password).

Tip:Use password attribute Set or return href attribute value The password part.

Example

Example 1

Return the URL of the specific area in the image map's username part:

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

Try it yourself

Example 2

Change the username part of the specific area in the image map:

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

Try it yourself

Syntax

Return the username attribute:

areaObject.username

Set the username attribute:

areaObject.username = username

属性值

描述
username 规定 URL 的用户名部分。

技术细节

返回值: 字符串值,代表 URL 的用户名部分。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 不支持 支持 不支持 支持