Skip to main content
Adding cross-browser compatibility
Source Link
JulienRioux
  • 3k
  • 2
  • 26
  • 40

Here is the solution I'm using:

const result = `${ window.location.protocol }//${ window.location.host }`;

EDIT:

To add cross-browser compatibility, use the following:

const result = `${ window.location.protocol }//${ window.location.hostname + (window.location.port ? ':' + window.location.port: '') }`;

Here is the solution I'm using:

const result = `${ window.location.protocol }//${ window.location.host }`;

Here is the solution I'm using:

const result = `${ window.location.protocol }//${ window.location.host }`;

EDIT:

To add cross-browser compatibility, use the following:

const result = `${ window.location.protocol }//${ window.location.hostname + (window.location.port ? ':' + window.location.port: '') }`;
Source Link
JulienRioux
  • 3k
  • 2
  • 26
  • 40

Here is the solution I'm using:

const result = `${ window.location.protocol }//${ window.location.host }`;