function HTMLqueryString(strURL, strParam)
{
var strVal = ""; try
{
// if strURL = "http://www.mySite.com/myPage.htm?param1=val1¶m2=val2"
var nIndex = strURL.indexOf("?");
if (nIndex > 0)
{
// cut strURL into "¶m1=val1¶m2=val2"
strURL = "&" + strURL.substring(nIndex + 1, strURL.length);
nIndex = strURL.indexOf("&"+ strParam + "=");
if(nIndex >= 0)
{
// jump to the position after the equal sign, if we're looking for
// param1, then strURL should contain 'val1¶m2=val2'
strURL = strURL.substring(nIndex + strParam.length + 2, strURL.length); // in case there are other parameters followed
nIndex = strURL.indexOf("&");
if(nIndex == -1) //find the target
strVal = strURL;
else
strVal = strURL.substring(0, nIndex); // strVal should be 'val1' now
}
}
}
catch(e){} return strVal;
}
{
var strVal = ""; try
{
// if strURL = "http://www.mySite.com/myPage.htm?param1=val1¶m2=val2"
var nIndex = strURL.indexOf("?");
if (nIndex > 0)
{
// cut strURL into "¶m1=val1¶m2=val2"
strURL = "&" + strURL.substring(nIndex + 1, strURL.length);
nIndex = strURL.indexOf("&"+ strParam + "=");
if(nIndex >= 0)
{
// jump to the position after the equal sign, if we're looking for
// param1, then strURL should contain 'val1¶m2=val2'
strURL = strURL.substring(nIndex + strParam.length + 2, strURL.length); // in case there are other parameters followed
nIndex = strURL.indexOf("&");
if(nIndex == -1) //find the target
strVal = strURL;
else
strVal = strURL.substring(0, nIndex); // strVal should be 'val1' now
}
}
}
catch(e){} return strVal;
}
解决方案 »
- 按钮替换
- 请问大家的工作流程是怎么样的,前端工程师与后端是如何交互配合的?
- 我用DW写了一个HTML+CSS的网页模板,在里面,我添加了谷歌的script广告代码,但是我本地测试浏览器打开老是被拦截,请问如何解决?
- 网页web 嵌套iframe问题 容易。。?
- 怎么用js隐藏body里没有标签的文字?
- 问个问题,关于判断iframe里面页面的高度
- 感谢本版朋友的帮助,散分100
- meizz(梅花雪)前辈请进,略表敬意。
- 求一段能左右移动的代码,效果如下连接所示
- 如何强制目录返回?急!谢谢!
- 请问如何接收从模式窗体中传回的数据并把它填在文本框里
- 如何制作一个类似框架能动态改变地表格的单元格的大小的表格?
<script>
url = location;
ar = url.replace(/(.*)\?/g,"").split(/[&=]/);
for(i=0;i<ar.length;i+=2)
eval(ar[i]+"="+ ar[i+1]);
document.write(dd);
</script>
test.htm
<script>
url = location;
ar = url.replace(/(.*)\?/g,"").split(/[&=]/);
for(i=0;i<ar.length;i+=2)
eval(ar[i]+"="+ ar[i+1]);document.write(room);
document.write("<br/>");
document.write(id);
</script>在地址栏输入:test.htm?room=304&id=1"
var s = window.location.search; //得到 ?dd=dddddddd;
if(s)
{
var a = s.split("\?");
var b = a[1].split("%26");
for(var i=0; i<b.length; i++)
{
var c = b[i].split("=");
alert("你传入的变量 "+ c[0] +" 的值是 "+ c[1]);
}
}
</script>
alert(HTMLqueryString(location.href,"dd")),进行修改也行。谢谢!!!!