Files
30-seconds-of-code/snippets/getProtocol.md
Isabelle Viktoria Maciohsek 920a0c390b Update snippet descriptions
2020-10-19 22:49:51 +03:00

299 B

title, tags
title tags
getProtocol browser,beginner

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:'