当我在www.example.com/about-us/user中使用下面的脚本时,它显示了整个url
<script type="text/javascript">
alert(document.URL);
</script>我只想在这里得到域名,比如example.com ..。是否有用于检索域名的javascript内置函数?
发布于 2013-09-04 09:16:36
很简单,就像:
alert(document.domain);发布于 2013-09-04 09:16:39
你试过这个吗?
alert(document.domain);发布于 2013-09-04 09:17:06
alert(location.hostname);或
alert(document.domain);https://stackoverflow.com/questions/18609824
复制相似问题