Files
30-seconds-of-code/snippets/js/s/current-page-protocol.md
Angelos Chalaris 9d032ce05e Rename js snippets
2023-05-19 20:23:47 +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:'