Files
30-seconds-of-code/snippets/getProtocol.md
Isabelle Viktoria Maciohsek 27c168ce55 Bake date into snippets
2021-06-13 13:55:00 +03:00

375 B

title, tags, firstSeen, lastUpdated
title tags firstSeen lastUpdated
getProtocol browser,beginner 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:'