location對象屬性
如下代碼:
<script type="text/javascript">
??? var host=window.location.host;
?? //var hash1=window.location.hash;
?? var hostname=window.location.hostname;
?? var href= window.location.href;
?? var pathname=window.location.pathname;
?? var port1=window.location.port;
?? var protocol=window.location.protocol;
?? //var search=window.location.search;
??? document.write("主機名和當前URL的端口號:"+host+"<br/>"+"錨點:"+"<br/>"+"主機名:"+hostname+"<br/>"+"完整的URL:"+href+"<br/>"+"當前URL的路徑部分為:"+pathname+"<br/>"+"端口號:"+port1+"<br/>"+"當前URL協議"+protocol+"<br/>")
?</script>
為什么hash,port,search這三個對象的屬性不能夠顯示出來?如果我的代碼格式錯誤,那么請問對的代碼格式是什么?
謝謝你的回答
2015-11-03
設個斷點不就看到 window.location的所有屬性了