Files
30-seconds-of-code/snippets/getProtocol.md
Isabelle Viktoria Maciohsek 52880f08ee Update document, window
2020-10-20 11:46:23 +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:'