location.host vs location.hostname and cross-browser compatibility?

后端 未结 6 1447
情话喂你
情话喂你 2020-11-29 14:59

Which one of these is the most effective vs checking if the user agent is accessing via the correct domain.

We would like to show a small js based \'top bar\' style

6条回答
  •  独厮守ぢ
    2020-11-29 15:31

    MDN: https://developer.mozilla.org/en/DOM/window.location

    It seems that you will get the same result for both, but hostname contains clear host name without brackets or port number.

提交回复
热议问题