Added getProtocol
This commit is contained in:
16
snippets/getProtocol.md
Normal file
16
snippets/getProtocol.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
title: getProtocol
|
||||||
|
tags: browser,beginner
|
||||||
|
---
|
||||||
|
|
||||||
|
Returns the protocol being used on the current page.
|
||||||
|
|
||||||
|
- Can be either `http:` or `https:`
|
||||||
|
|
||||||
|
```js
|
||||||
|
const getProtocol = () => window.location.protocol;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
getProtocol(); // 'https:'
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user