这篇文章给大家详细介绍了html页面跳转及参数传递问题,希望能帮助到大家。
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页面跳转及参数传递问题,希望能帮助到大家。
相关推荐:
以上就是HTML页面跳转及参数传递问题的详细内容,更多请关注php中文网其它相关文章!
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号