Web API URL.protocol Property Last Updated : 27 Nov, 2020 Comments Improve Suggest changes Like Article Like Report The Web API URL.protocol property is used to get USVString containing the protocol scheme of the URL. Syntax: var str = URL.protocol Return Value: This property returns a USVString containing the protocol scheme of the URL. Example 1: HTML <!DOCTYPE html> <html> <body> <h1>GeeksforGeeks</h1> <button onclick="get()"> Click on Me! </button> <script type="text/javascript"> function get() { var url = new URL( 'https://www.geeksforgeeks.org/GeeksforGeeks'); console.log( "protocol of current URL is :", url.protocol); } </script> </body> </html> Output: Example 2: HTML <!DOCTYPE html> <html> <body> <h1>GeeksforGeeks</h1> <div id="abc"></div> <br><br> <button onclick="get()"> Click on Me! </button> <script type="text/javascript"> function get() { var url = new URL( 'https://www.geeksforgeeks.org/GeeksforGeeks'); a = document.getElementById("abc"); a.innerHTML = "protocol of current URL is : " + url.protocol; } </script> </body> </html> Output: Supported Browsers: SafariOperaChromeEdgeFirefox Comment More infoAdvertise with us Next Article Web API URL.protocol Property T taran910 Follow Improve Article Tags : Web Technologies HTML HTML-DOM HTML-Property Web-API +1 More Similar Reads Web API URL.search Property The Web API URL.search property is used to get USVString which is a search string or a query string. This string contains a "?" followed by the parameters of the URL. Syntax: var str = URL.search Return Value: This property returns a USVString search string. Example 1: HTML <!DOCTYPE html> 1 min read Web API URL.port Property The Web API URL.port property is used to get USVString containing the port number of the URL. Syntax: var str = URL.port Return Value: This property returns a USVString containing the port number of the URL. Example 1: HTML <!DOCTYPE html> <html> <body> <h1>GeeksforGeeks</ 1 min read Web API URL.username Property The Web API URL.username property returns a USVString containing the username specified before the domain name of the URL Syntax: var str = URL.username Return Value: This property returns a USVString containing the username specified before the domain name of the URL. Example 1: HTML <!DOCTYPE h 1 min read Web API URL.origin Property The Web API URL.origin property returns a USVString containing the origin of the URL. Syntax: var str = URL.origin Return Value: This property returns a USVString containing the origin of the URL. Example 1: HTML <!DOCTYPE html> <html> <body> <h1>GeeksforGeeks</h1> < 1 min read Web API URL.pathname Property The Web API URL.pathname property is used to get USVString containing an initial â/â followed by the path of the URL. Syntax: var str = URL.pathname Return Value: This property returns a USVString containing the pathname of the URL. Note: If there is no path set for the URL, so it will Return only / 1 min read Like