Current page protocol

JavaScript, Browser · Oct 20, 2020

Gets the protocol being used on the current page.

  • Use Window.location.protocol to get the protocol (http: or https:) of the current page.
const getProtocol = () => window.location.protocol;
getProtocol(); // 'https:'

More like this

  • Scroll position

    Returns the scroll position of the current page.

    JavaScript, Browser · Oct 19, 2020

  • URL parameters as object

    Creates an object containing the parameters of the current URL.

    JavaScript, Browser · Oct 22, 2020

  • Redirect to HTTPS

    Redirects the page to HTTPS if it's currently in HTTP.

    JavaScript, Browser · Oct 22, 2020