I
I
Ignat Khaylov2018-09-17 15:24:43
JavaScript
Ignat Khaylov, 2018-09-17 15:24:43

How does javascript determine the protocol of a site?

I have a client script that, depending on the protocol of the domain it's running on, pulls resources from my server, either via https: or http. In the script itself there is a simple check

//..something code..
const url = document.location.protocol === "https:" ? `https://myserver.com` : `http://myserver.com`;
//..something code..

And everything is fine, but on one secure site where my script is running, resources are pulled over http. I got into the debugger and saw something strange: the value of document.location.protocol is "about:".
Has anyone experienced something similar? What is the "about:" protocol anyway? Maybe someone knows how JS determines the protocol of the page on which it works?
Checked in the latest versions of Chrome, Mozilla, Yandex.Browser and Safari.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AngReload, 2018-09-17
@AngReload

about are browser service pages, for example, a blank page is about:blank, a new tab is about:newtab, and so on. I do not know how it can be that the script on the site sees this protocol.
https://ru.m.wikipedia.org/wiki/About:_URI

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question