7
可能重複:
Use the get parameter of the url in javascript如何從Javascript中的URL中提取GET參數?
假設我有這個網址:
s = 'http://mydomain.com/?q=microsoft&p=next'
在這種情況下,我如何提取 「微軟」 從字符串? 我知道,在蟒蛇,這將是:
new_s = s[s.find('?q=')+len('?q='):s.find('&',s.find('?q='))]
'decodeURIComponent'。 'escape' /'unescape'幾乎總是一個錯誤。 – bobince 2009-10-26 10:18:57
此外,這不會與URL是一個字符串。由於它使用方法搜索,我想url應該是window.location。除了這兩個問題,似乎工作正常,導入一個庫到這個任務肯定是一個矯枉過正。 – fotanus 2014-01-09 12:00:16