location.search是从当前URL的?号开始的字符串
如:
http://www.51js.com/viewthread.php?tid=22720
它的search就是?tid=22720
要获取完整的地址
var url = window.location.search.substring(1,location.search.length);
转载于:https://www.cnblogs.com/ufo0303/archive/2006/08/18/480327.html