
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to return the protocol (http or https) of the web page with JavaScript?
Use the window.location object to return the protocol. The window.location.protocol will return the web protocol i.e. whether it’s http or https −
Example
<!DOCTYPE html> <html> <body> <script> document.write("https or https: <br>The protocol is:"+window.location.protocol); </script> </body> </html>
- Related Questions & Answers
- How to get the protocol and page path of the current web page in JavaScript?
- Difference Between HTTP and HTTPS
- How to return or set the width of the columns with JavaScript?
- Differentiate between HTTP and HTTPS in Computer Network.
- How do I redirect my web page with JavaScript?
- Set the navigation bar to stay at the top of the web page with CSS
- Set the navigation bar to stay at the bottom of the web page with CSS
- How to make the web page height to fit screen height with HTML?
- How to return the color of the text with JavaScript?
- How to completely fill web page with HTML canvas?
- Display all the values of an array in p tag on a web page with JavaScript
- How to get the value associated with the http-equiv or name attribute in HTML?
- JavaScript: How to return True if the focus is on the browser tab page?
- As HTTP is a stateless then how to maintain the session between web browser and web server?
- With JavaScript how can I find the name of the web browser, with version?
Advertisements