SYNCERのロゴ
アイキャッチ画像

HTMLHyperlinkElementUtils.password - ハイパーリンクのパスワード

passwordは、HTMLHyperlinkElementUtilsのプロパティです。ハイパーリンクに設定されているURLのパスワードを反映します。

概要

名前
password
所属
HTMLHyperlinkElementUtils
IDL
[CEReactions] attribute USVString password;
仕様書
https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-password

説明

ハイパーリンクに設定されているURLのパスワードを表す文字列。存在しない場合は空の文字列を返す。

チュートリアル

値は取得、代入、どちらもできます。

HTML

<a href="https://username:password@example.com/" id="hoge">リンク</a>

JavaScript

// HTMLHyperlinkElementUtilsを取得
var element = document.getElementById( "hoge" ) ;

取得

JavaScript

var value = element.password ;	// "password"

代入

JavaScript

element.password = "newpassword" ;	// <a href="https://username:newpassword@example.com/" id="hoge">リンク</a>

デモ

HTMLHyperlinkElementUtils.passwordを取得するデモです。

<!-- このコードは編集できます。 -->

<!DOCTYPE html>
<html>
<body>
<a href="https://hoge:fuga@syncer.ch/Basic/" id="hoge" target="_blank">リンク</a>
<hr>

<script>
var element = document.getElementById( "hoge" ) ;

console.log( element.password ) ;
document.body.appendChild( new Text( element.password ) ) ;
</script>
</body>
</html>

サポート状況

ChromeFirefoxSafariEdgeIEOperaiOS SafariAndroid
32+ 26+ 10+×× 19+ 10.0+×
  • Twitterでシェア
  • Facebookでシェア
  • Google+でシェア
  • はてなブックマークでシェア
  • pocketに保存
  • LINEでシェア
更新履歴
2017年9月17日 (日)
コンテンツを公開しました。