Javascript examples for Browser Object Model:Location
The protocol property sets or gets the protocol of the current URL, including the colon (:).
Set the protocol property with the following Values
Value | Type | Description |
---|---|---|
protocol | String | The protocol of the URL. |
Possible values: file: ftp: http: https: mailto: etc..
A String, representing the protocol of the current URL, including the colon (:)
The following code shows how to return the protocol of the current URL:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// w w w .j a v a 2s . c o m var x = location.protocol; document.getElementById("demo").innerHTML = x; } </script> </body> </html>