Web API URL.password Property
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 >w3wiki</ h1 > < button onclick = "get()" x = '15' y = '30' > Click on Me! </ button > < script type = "text/javascript" > function get() { var url = new URL( 'https://password:gfg@www.w3wiki.net/href#ExampleHash'); console.log("password of current URL is :", url.password); } </ script > </ body > </ html > |
Output:
Example 2:
HTML
<!DOCTYPE html> < html > < body > < h1 >w3wiki</ 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:gfg@www.w3wiki.net/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
Contact Us