html是否可以接受get方式变量?

因为考虑到速度问题,我的页面用.html来撰写
现在想写个变量来进行操作不知道是否可能

如http://xx.com/1.html?test=1

页面中能否得知test值?
---------------------------------------------------------------

// 从url 字符串中提取变量的值
function GetQueryValue(sorStr,panStr)
{
var vStr="";
if (sorStr==null ¦ ¦ sorStr=="" ¦ ¦ panStr==null ¦ ¦ panStr=="") return vStr;
sorStr = sorStr.toLowerCase();
panStr += "=";
var itmp=sorStr.indexOf(panStr);
if (itmp<0){return vStr;}
sorStr = sorStr.substr(itmp + panStr.length);
itmp=sorStr.indexOf("&");
if (itmp<0)
{
return sorStr;
}
else
{
sorStr=sorStr.substr(0,itmp);
return sorStr;
}
}

// 获得url字符串
var strGetQuery = document.location.search;
// 获得csdnstyle 参数的值
var stylevalue = GetQueryValue(strGetQuery,'csdnstyle')

Published At
Categories with Web编程
Tagged with
comments powered by Disqus