如何使用Javascript或Jquery從URL獲取參數值更簡單!從URL中提取查詢
我得到這個URL
http://website.in/instant/#mystring
而且我想
mystring
從URL
如何使用Javascript或Jquery從URL獲取參數值更簡單!從URL中提取查詢
我得到這個URL
http://website.in/instant/#mystring
而且我想
mystring
從URL
window.location.hash
返回以 「#」 散,所以你可以使用:window.location.hash.substr(1)
你想window.location.hash
在#後只有字符串。
我知道!但是,如何從查詢中提取確切的字符串? – 2012-03-31 12:58:56
@NarendraRajput:我看你有答案eveywhere。只需在需要數據的地方執行「window.location.hash」即可。 – 2012-03-31 17:01:39
@narendra as Jasd回答它應該可以工作 – Devjosh 2012-03-31 13:01:59
'window.location.hash.replace('#','')'是安全的,因爲一些舊的瀏覽器(IE <= 6我認爲)返回散列字符串,沒有前導# 。 – 2012-03-31 15:34:09