Files
30-seconds-of-code/javascript/snippets/get-protocol.md
2023-05-01 22:35:56 +03:00

375 B

title, type, tags, cover, dateModified
title type tags cover dateModified
Current page protocol snippet
browser
bamboo-lamp 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:'