A网站跳转B网站并传值-----window.open
2017-03-02 17:15
330 查看
A网站跳转B网站并传值-----window.open
意思如图:
这里我们做一个名字为A.html和B.html实现该效果的demo,其中用到window.open()的方式进行传值。
A.html源码:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>A页面点击a后主跳转</title> </head> <style> div { width: 400px; height: 50px; margin: 100px auto; } a { float: left; width: 100px; height: 50px; line-height: 50px; font-size: 18px; text-align: center; } a:nth-child(1) { background: red; } a:nth-child(2) { background: orange; } a:nth-child(3) { background: green; } a:nth-child(4) { background: pink; } </style> <body> <div> <a onclick="ulrHtml(1)">B链接1选项</a> <a onclick="ulrHtml(2)">B链接2选项</a> <a onclick="ulrHtml(3)">B链接3选项</a> <a onclick="ulrHtml(4)">B链接4选项</a> </div> <script> function ulrHtml(num) { var toUrl = "B.html?" + num window.open(toUrl); } </script> </body> </html>
B.html源码:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>B被跳转的子页面</title> <script src="http://libs.baidu.com/jquery/1.8.3/jquery.js"></script> <style> ul { width: 400px; height: 50px; margin: 100px auto; } ul li { float: left; width: 100px; height: 50px; line-height: 50px; font-size: 18px; text-align: center; } .on { background: red; } </style> </head> <body> <ul id="tab"> <li>第一项</li> <li>第二项</li> <li>第三项</li> <li>第四项</li> </ul> <script> setTimeout(function(){ var location = window.location.href; var href = location + ""; var href_part = href.split('?'); var num = (href_part[1]) * 1; $('#tab li:nth-child(' + num + ')').addClass('on'); }); </script> </body> </html>
好了,这时候可以测试下了~~
相关文章推荐
- frame,window.open(),等相关的跳转总结
- location.href、parent.location.href、top.location.href、 window.open实现页面跳转
- 跳转打开网页(open, window.location)
- 完好用户体验: 活用window.location与window.open解决页面跳转问题
- [ExtJS5学习笔记]第二十五节 利用window.open()函数实现ExtJS5的登陆页面跳转
- js onclick跳转页面方法(window.open)
- js 中实现页面跳转的方法(window.location和window.open的区别)
- [ExtJS5学习笔记]第二十五节 利用window.open()函数实现ExtJS5的登陆页面跳转
- [ExtJS5学习笔记]第二十五节 利用window.open()函数实现ExtJS5的登陆页面跳转
- 伪造A标签跳转(非window.open)Jquery
- window.location与window.open()的区别 "top.location.href"是最外层的页面跳转
- 完善用户体验: 活用window.location与window.open解决页面跳转问题
- js模拟form表单提交数据, js模拟a标签点击跳转,避开使用window.open引起来的浏览器阻止问题
- location.href、parent.location.href、top.location.href、 window.open实现页面跳转
- frame,window.open(),等相关的跳转总结
- 通过window.open跳转得到上一个页面的URL
- mui 每次页面跳转用mui.openWindow会不会占用很大内存?
- 论div,button,input点击跳转页面不同window.open()
- location.href、parent.location.href、top.location.href、 window.open实现页面跳转
- js 用 window.open()方法跳转到新页面并且用post方式传参