Prepare repository for merge
This commit is contained in:
19
javascript/snippets/get-protocol.md
Normal file
19
javascript/snippets/get-protocol.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
title: Current page protocol
|
||||
type: snippet
|
||||
tags: [browser]
|
||||
cover: bamboo-lamp
|
||||
dateModified: 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:'
|
||||
```
|
||||
Reference in New Issue
Block a user