不同web如何通讯之 html页面获取传递的参数
2007-07-30 15:26
621 查看
有时候在项目开发过程中,因为要进行数据传递,或者进行重定向。如果是使用同一个平台,比如jsp,或者asp,那么文件非常好解决,但是我们在开发过程中,特别是具体接口功能的页面,就无法规定使用何种语言,
所有可以是用html进行转换,那么如何获取传递的参数,看下面的js。
<script language="JavaScript">
var pos,str,para,parastr,tempstr1;
tempstr="";
str = window.location.href;
pos = str.indexOf("?")
parastr = str.substring(pos+1);
document.write("<br>文件路径:"+str);
if (pos>0){
document.write("<br>所有参数:"+parastr);
}
else
{
document.write ("无参数");
}
// 文件路径:hello.html?a=1&b=2&c=3
// 所有参数:a=1&b=2&c=3
// 参数0:a等于:1
// 参数1:b等于:2
// 参数2:c等于:3
if (str.indexOf("&")>0){
para = parastr.split("&");
for(i=0;i<para.length;i++)
{
tempstr1 = para[i];
pos = tempstr1.indexOf("=");
//document.write (tempstr1.substring(0,pos));
document.write ("<br>参数"+i+":"+tempstr1.substring(0,pos));
document.write ("等于:"+tempstr1.substring(pos+1));
}
}
</script>
未完,代完善
所有可以是用html进行转换,那么如何获取传递的参数,看下面的js。
<script language="JavaScript">
var pos,str,para,parastr,tempstr1;
tempstr="";
str = window.location.href;
pos = str.indexOf("?")
parastr = str.substring(pos+1);
document.write("<br>文件路径:"+str);
if (pos>0){
document.write("<br>所有参数:"+parastr);
}
else
{
document.write ("无参数");
}
// 文件路径:hello.html?a=1&b=2&c=3
// 所有参数:a=1&b=2&c=3
// 参数0:a等于:1
// 参数1:b等于:2
// 参数2:c等于:3
if (str.indexOf("&")>0){
para = parastr.split("&");
for(i=0;i<para.length;i++)
{
tempstr1 = para[i];
pos = tempstr1.indexOf("=");
//document.write (tempstr1.substring(0,pos));
document.write ("<br>参数"+i+":"+tempstr1.substring(0,pos));
document.write ("等于:"+tempstr1.substring(pos+1));
}
}
</script>
未完,代完善
相关文章推荐
- hTML 如何在不同页面上传递参数( 1 )
- ext6如何不同页面传递参数问题
- 纯html静态页面怎么获取参数(用javascript传递页面参数)
- Web报表页面如何传递中文参数
- JQuery拼接html页面时JSONObject作为onclick参数如何传递?
- 如何在HTML页面,访问request 对象里边传递的参数
- 纯html静态页面怎么获取参数(用javascript传递页面参数)
- iframe之间静态html页面如何传递参数?
- HTML页面地址栏参数传递与获取
- 两个不同HTML页面之间参数传递
- js_html_input中autocomplete="off"在chrom中失效的解决办法 使用JS模拟锚点跳转 js如何获取url参数 C#模拟httpwebrequest请求_向服务器模拟cookie发送 实习期学到的技术(一) LinqPad的变量比较功能 ASP.NET EF 使用LinqPad 快速学习Linq
- HTML页面参数的传递与获取
- jQuery设置和获取HTML、文本和值和Javascript获取HTML静态页面参数传递值示例
- 纯html页面如何提交、传递参数、以及对身份进行验证
- 如何给html元素的onclick事件传递参数即如何获取html标签的data
- 在一个页面文件中(JSP 或者HTML)使用href 跳转另一个页面时使用Js中获取传递过来的参数
- Web报表页面如何传递中文参数
- 如何使用js来实现通过href完成多个html页面之间的传递参数
- 如何给html元素的onclick事件传递参数(即如何获取html标签的data-*属性)
- HTML页面如何获取路径上的参数