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

后端 未结 6 1459
情话喂你
情话喂你 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:18

    As a little memo: the interactive link anatomy

    --

    In short (assuming a location of http://example.org:8888/foo/bar#bang):

    • hostname gives you example.org
    • host gives you example.org:8888

提交回复
热议问题