title | tags |
---|---|
getProtocol |
browser,beginner |
Returns the protocol being used on the current page.
- Use
window.location.protocol
to get the protocol (http:
orhttps:
) of the current page.
const getProtocol = () => window.location.protocol;
getProtocol(); // 'https:'