Seven blog

天行健,君子以自强不息

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

获取Html页面的传入参数

我们可以通过*.asp?country=86来获取参数,是不是也可以通过*.html?country=86来获取参数呢

 1<html>
 2<title>
 3Call xmlhttp.
 4</title>
 5<body>
 6<div id="div_RightBarBody" ></div>
 7<script language="javascript">
 8function RequestByGet(nProducttemp,nCountrytemp)
 9{
10    var xmlhttp
11
12    if (window.XMLHttpRequest)  
13    {  
14         //isIE   =   false;  
15         xmlhttp   =   new   XMLHttpRequest();  
16    }
  
17    else if (window.ActiveXObject)
18    {  
19         //isIE   =   true;  
20         xmlhttp   =   new   ActiveXObject("Microsoft.XMLHTTP");  
21    }

22                 
23    //Web page location.
24    var URL="http://staging2:3002/products/includes/000rightbar111.asp?nProduct=" + nProducttemp + "&nCountry=" + nCountrytemp;
25    xmlhttp.open("GET",URL, false);
26   
27    xmlhttp.send(null);
28    var result = xmlhttp.status;
29   
30    //OK
31    if(result==200)
32    {
33        document.getElementById("div_RightBarBody").innerHTML=xmlhttp.responseText;
34    }

35    xmlhttp = null;
36}

37
38function QueryString(param)
39{
40    var query = window.location.search;
41    var iLen = param.length;
42    var iStart = query.indexOf(param);
43    if (iStart == -1)
44    return "";
45    iStart += iLen + 1;
46    var iEnd = query.indexOf("&", iStart);
47    if (iEnd == -1)
48        return query.substring(iStart);
49    else
50        return query.substring(iStart, iEnd);
51}

52
53var nProduct = QueryString("nProduct");
54var nCountry = QueryString("nCountry");
55RequestByGet(nProduct,nCountry)
56
57</Script>
58</body>
59</html>
60
posted on 2007-08-30 14:21  china-seven  阅读(344)  评论(0)    收藏  举报