亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

這個哪里有問題,求教,感謝

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>location</title>

</head>

?<script type="text/javascript">

?var kl=[protocol,host,pathname,search,hash];

? var num;

? for(num=0;num<=4;num++)

? {

? ? ? document.write(location.(kl[num]);

? }

?</script>

<body>

</body>

</html>


正在回答

3 回答

錯誤1:數組中的項都是location對象的屬性,形式上應寫為:location.protocol等等;

錯誤2:for循環本身寫得有問題;如果你想這么寫,那么上面的數組中應該全是字符串屬性,那樣的話應寫為:["protocol","host"]等等。

以上

3 回復 有任何疑惑可以回復我~
#1

路途7 提問者

非常感謝!
2017-03-16 回復 有任何疑惑可以回復我~

??? document.write(location.(kl[num]);少了kuohao

0 回復 有任何疑惑可以回復我~

其實也可以寫成這樣:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>location</title>
</head>
?<script type="text/javascript">
?var kl=[location.protocol,location.host,location.pathname,location.search,location.hash];
? for(var num=0;num<=4;num++)
? {
????? document.write(kl[num]+"<br>");
? }
?</script>
<body>
</body>

</html>


1 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

這個哪里有問題,求教,感謝

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號