2012-02-07 42 views

回答

1

首先讓做一個很好的查詢字符串搜索在JS

function querySt(qsName, url) 
     { 
      var theUrl; 
      if (url == null || url == undefined) 
       theUrl = window.location.search.substring(1); else theUrl = url; 
      var g = theUrl.split("&"); 
      for (var i = 0; i < g.length; i++) { 
       var pair = g[i].split("="); 
       if (pair[0].toLowerCase() == qsName.toLowerCase()) 
       { 
        return pair[1]; 
       } 
      } 
      return null; 
     } 



$(function(){ 
    if (querySt("open")!='true') return; 

}); 
0

您可以測試location.href用正則表達式:

if (location.href.match(/open=true/) 
    // do something 

你可能想在正則表達式的工作,雖然,以確保它爲你工作。

相關問題