Answer the question
In order to leave comments, you need to log in
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..
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question