[javascript]document.URL 與 location.href 的區別

document.URL 與 location 二者有兩點區別: 1.document.URL 是字串2.document.URL 唯讀3.location 是物件4.location 可以拿來控制網頁行進 location 有以下方法hash 讀取或設定錨點(錨點就是#test 類似這意思)host 讀取或設定主網域名稱hostname讀取或設......

詳細

[JavaScript][尋找字串]indexOf()

在 javascript中有尋找字串的方式 就是使用 indexOf() 來尋找字串 例如 var str="Hello Zoearth!" alert(str.indexOf("Zoe")); //結果 6 alert(str.indexOf("Hello")); //結果 0 alert(str.indexOf("Moon")); //結果 -1 要注意的是當找到的位置為0的時候直接判斷會變成 F......

詳細

留言板

歡迎留下建議與分享!希望一起交流!感恩!

comments powered by Disqus