html页面跳转:
window.open(url, , width=600,height=400);
第二个参数:_self,在当前窗口打开窗口;_blank(默认值),在另外的新建窗口打开新窗口;
window.location.href=http://www.jb51.net; //在同当前窗口中打开窗口 window.history.back(-1); //返回上一页面 <a href="http://www.baidu.net" target="_blank">
html参数传递:
1. url传参:
第一个页面(a.html):
var obj = a.value; //传给弹出页面参数 var url = 'jxb.html?obj='+obj; url = encodeuri(url); window.open(url, , width=600,height=400);
第二个页面(b.html):
var url = decodeuri(window.location.href); var argsindex = url .split(?obj=); var arg = argsindex[1];
注:中文传输:可以在页面a用encodeuri 编码url 在b页面用decodeuri解码url
2. cookie传参:
function setcookie(cname,cvalue){ document.cookie = cname + = + cvalue; } function getcookie(cname){ var name = cname + =; var ca = document.cookie; }
3. localstorage对象传参:
a.html:
var p = doucment.getelementbyid('要获取字符串的p id名'); localstorage.string = p.textcontent;
b.html:
var p = doucment.getelementbyid('要写入的p id名'); p.textcontent = localstorage.string;
4. window.opener()
父页面:
<input type="text" name="textfield" id="textfield"/>
window.open(子页面.html);
子页面:
window.opener.document.getelementbyidx('textfield').value='123123123';
总结
以上内容就是html页面跳转及参数传递问题,希望能帮助到大家。
相关推荐:
javascript页面跳转间的常用方法有哪些
web页面跳转并取值的方法指导
关于html页面跳转的7篇文章推荐
以上就是html页面跳转及参数传递问题的详细内容。
