How to turn a domain into exile, not knowing the Protocol?
Have a domain name, type example.com which needs to be turned into a valid link in HTML template, not knowing the true Protocol (HTTP(S)).
The website can be HTTP-only or HTTPS-only, and need to accurately access the correct.
Links without Protocol resolvase as a local, and with just a double slash (//example.com) will resolvida on the Protocol that is used on the page.
Browsers (eg. Chrome) as it can be resolved need an address for the domain, but how to do it in simple HTML?
Allowed to use JS.
Gregoria.Kreiger answered on March 23rd 20 at 19:14
In fact, it is a problem of specific sites - they should always be available via HTTP, though with an unconditional redirect to HTTPS. Accordingly, it is sufficient to simply specify the Protocol http://.
But if you really want to bother, it is possible for the client in the background to make a request to the site address with https:// and if you come the response is 2XX or 3XX, to substitute this Protocol.
Another way to see if the website of a particular Protocol but to make there request does not exist.
alf_Moore answered on March 23rd 20 at 19:16
In normal situation the link http://habr.com/ru/company/vivaldi/blog/454936/ will work out a redirect to https.
Ie you can give links in http.
If the site is https-only, can not redirects, etc. - it is purely their problem, let them decide.