
In order to know the network protocol (HTTP, HTTPS, FTP, SMTP, SSH, FILE e.t.c) of the current page we can make use of the window.location.protocol object in Javascript,
var urlProtocol = window.location.protocol;
File: pageProtocol.html
<html>
<head>
<title>Get current page Protocol using JavaScript</title>
</head>
<body onload="getCurrentPageProtocol()">
<div id="pageDetails"></div>
<script>
function getCurrentPageProtocol() {
var currPageURL = window.location.protocol;
document.getElementById("pageDetails").innerHTML = "<strong>Current Page Protocol : </strong>" + currPageURL;
}
</script>
</body>
</html>
- How to get UTC (GMT) time using JavaScript
- Submit html form on dropdown menu value selection or change using javascript
- How to detect Browser and Operating System Name and Version using JavaScript
- JavaScript : Get current page address
- [javaScript] Convert text case to lowercase
- How to check if a String contains substring or a word using javaScript
- Writing your first Hello, World! 🌍 JavaScript code Tutorial
- JavaScript: Check if variable is a number
- How to send email from JavaScript HTML using mailto
- Meaning of javascript:void(0) explained with example
- How to get query string in JavaScript HTML location.search
- Javascript convert text case from uppercase to lowercase
- Loading previous page using html button using JavaScript
- JavaScript : Get url protocol HTTP, HTTPS, FILE or FTP
- How to get current URL Location using Javascript HTML
- Detect if Cookies are enabled using JavaScript
- Write javaScript code in Swedish using FikaScript
- Add Animated Scrolling to Html Page Title Script
- JavaScript: Convert an Image into Base64 String
- Remove items from JavaScript array
- Send Extra Data with Ajax Get or Post Request
- How to Print from JavaScript HTML using window.print
- Get Device Screen Width and Height using javaScript
- Examples: Convert String to int in JavaScript
- npm WARN saveError ENOENT: no such file or directory, open /mnt/c/package.json
- Fix: Cannot contact reCAPTCHA. Check your connection and try again. - Google
- Java SE JDBC with Prepared Statement Parameterized Select Example - Java
- Comparator with Lambda Examples - Java
- Android read text file from internal storage - Android
- The Date Command and its usage [Linux - Unix - macOS] - Linux
- Are Windows Notepad files recoverable? - NotepadPlusPlus
- TextEdit save file with txt extension - MacOS
- Android Studio : Build Tools 23.0.0 rc1 is deprecated - Android-Studio