Files
30-seconds-of-code/js/s/get-protocol.md
Angelos Chalaris 5c913d20bd Reorganize snippets
2023-05-03 21:19:02 +03:00

396 B

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