HTML页面跳转及参数传递问题
window.open(url, "", "width=600,height=400"); 第二个参数:_self,在当前窗口打开窗口;_blank(默认值),在另外的新建窗口打开新窗口; window.location.href="https://www.jb51.net"; //在同当前窗口中打开窗口 window.history.back(-1); //返回上一页面 <a href=http://www.jb51.net/web/"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 div = doucment.getElementById('要获取字符串的DIV ID名'); localStorage.string = div.textContent; b.html: var div = doucment.getElementById('要写入的DIV ID名'); div.textContent = localStorage.string; 4. window.opener() 父页面: <input type="text" name="textfield" id="textfield"/> window.open("子页面.html"); 子页面: window.opener.document.getElementByIdx('textfield').value='123123123'; 总结 以上所述是小编给大家介绍的HTML页面跳转及传递参数问题,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持! (编辑:海西站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 换肤漏洞竟连累Winamp播放器
- sql-server – 推荐的SSD设置
- entity-framework – SQL FileStream Entity Framework存储
- HTML表格标记教程(12):边框样式属性FRAME
- 详解HTML元素的height、offsetHeight、clientHeight、scrol
- sql-server – 我可以在2008服务器上使用SQL Server Manage
- 详解iframe的src指向的内容不刷新的解决办法
- Hyper-V 和 VMware 虚拟机软件共存的设置方法
- 三星12X DVD刻录机即将上市
- sql – 如何在Rails中创建“即将到来的生日”模块?