Files
30-seconds-of-code/snippets/get-protocol.md
Angelos Chalaris 61200d90c4 Kebab file names
2023-04-27 21:58:35 +03:00

20 lines
395 B
Markdown

---
title: Current page protocol
tags: browser
cover: bamboo-lamp
firstSeen: 2020-10-07T01:40:53+03:00
lastUpdated: 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.
```js
const getProtocol = () => window.location.protocol;
```
```js
getProtocol(); // 'https:'
```