Files
30-seconds-of-code/snippets/getProtocol.md
2022-06-08 12:30:49 +03:00

431 B

title, tags, expertise, cover, firstSeen, lastUpdated
title tags expertise cover firstSeen lastUpdated
Current page protocol browser beginner blog_images/bamboo-lamp.jpg 2020-10-07T01:40:53+03:00 2020-10-20T11:46:23+03:00

Gets the protocol being used on the current page.

  • Use Window.location.protocol to get the protocol (http: or https:) of the current page.
const getProtocol = () => window.location.protocol;
getProtocol(); // 'https:'