最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501
当前位置: 首页 - 科技 - 知识百科 - 正文

JS父页面与子页面相互传值方法_javascript技巧

来源:懂视网 责编:小采 时间:2020-11-27 21:20:36
文档

JS父页面与子页面相互传值方法_javascript技巧

JS父页面与子页面相互传值方法_javascript技巧:一、子页面是父页面通过window.open弹出的情况子页面要向父页面传值,只要在document前面加window.opener即可。 如: 1.父页面代码: 无标题文档title>head>function tanchu(){ window.open(Untitled-5.html); }script
推荐度:
导读JS父页面与子页面相互传值方法_javascript技巧:一、子页面是父页面通过window.open弹出的情况子页面要向父页面传值,只要在document前面加window.opener即可。 如: 1.父页面代码: 无标题文档title>head>function tanchu(){ window.open(Untitled-5.html); }script

一、子页面是父页面通过window.open弹出的情况
子页面要向父页面传值,只要在document前面加window.opener即可。
如:
1.父页面代码:




无标题文档title><BR>head><BR><script language="javascript"><BR>function tanchu()<BR>{<BR> window.open("Untitled-5.html"); <BR>}<BR>script><BR><body><BR> <form id="form1" name="form1" method="post" action=""><BR> <label> <input type="submit" name="button" id="button" value="提交"<BR> onclick="tanchu()" /><BR> label> <label> <input type="text" name="textfield" id="textfield" /><BR> label><BR> form><BR></body><BR></html><BR>2.子页面代码:</P> <P><html xmlns="http://www.w3.org/1999/xhtml"><BR><head><BR><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><BR><title>无标题文档title><BR>head><BR><script language="javascript"><BR>function aaa()<BR>{<BR> window.opener.document.getElementByIdx('textfield').value='123123123';<BR>}<BR>script><BR><body><BR> <form id="form1" name="form1" method="post" action=""><BR> <label> <input type="submit" name="button" id="button" value="提交"<BR> onclick="aaa()" /><BR> label><BR> form><BR></body><BR></html><BR>二、子页面是iframe框架中的页面情况<p>子页面要向父页面传值,只要在document前面加parent即可。 <BR>1.父页面代码:</P> <P><html xmlns="http://www.w3.org/1999/xhtml"><BR><head><BR><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><BR><title>无标题文档title><BR>head><BR><body><BR> <form id="form1" name="form1" method="post" action=""><BR> <label> <input type="text" name="textfield" id="textfield" /><BR> label><BR> iframe><BR> form><BR></body><BR></html><BR>2.子页面代码</P> <P><html xmlns="http://www.w3.org/1999/xhtml"><BR><head><BR><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><BR><title>无标题文档title><BR>head><BR><script language="javascript"><BR>function aa()<BR>{ <BR> var a=parent.document.getElementByIdx('textfield').value;<BR> alert(a); <BR>}<BR>script><BR><body><BR> <form id="form1" name="form1" method="post" action=""><BR> <label> <input type="submit" name="button" id="button" value="提交"<BR> onClick="aa()" /><BR> label><BR> form><BR></body><BR></html> </p><p><script type="text/javascript" src="https://jss.51dongshi.com/pcwz/dysph.js"></script><p><strong>声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com</strong></p></div> <div class="downbox clearfix"> <div class="ico"><img src="https://js.51dongshi.com/tpl/pc2/images/document.png" alt="文档"></div> <div class="txt"> <h4>JS父页面与子页面相互传值方法_javascript技巧</h4> <div class="co">JS父页面与子页面相互传值方法_javascript技巧:一、子页面是父页面通过window.open弹出的情况子页面要向父页面传值,只要在document前面加window.opener即可。 如: 1.父页面代码: 无标题文档title>head>function tanchu(){ window.open(Untitled-5.html); }script</div> <div class="tj"><b>推荐度:</b><div class="tj_stars_list"><i class="tj_stars tj_05"></i></div></div> </div> <div class="btn"> <a href="javascript:;" class="html2word" data-model="article" data-id="avdsah" title="文档下载"> <b>点击下载本文</b> <span>文档为doc格式</span> </a> </div> </div> <script>keji_detail_ga('article_content_bottom');</script> <div class="tvideo_tag"> 标签: <a href="/tlist-9297/">方法</a> <a href="/tlist-59738/">js</a> <a href="/tlist-124222/">相互</a> </div> <div class="tvideo_box tvideo_box_tab"> <div class="hd"> <ul><li class="on">热门焦点</li><script>keji_detail_ga('hot_jiaodian_tab_title');</script></ul> </div> <div class="bd"> <ul class="ult_jpic clearfix"> <script>get_hot_jiaodian_content('wz_hot_jiaodian',33,'hot',1);</script> </ul> </div> </div> </div> <!--中间文章 end--> <!--右侧专题 star--> <div class="ult_zt"> <script>keji_detail_ga('article_right_top');</script> <div class="ult_ztbox"> <h4>最新推荐</h4> <ul class="tvideo_r_a clearfix"> <script>get_detail_right('wz_right_new',33,'')</script> </ul> </div> <script>keji_detail_ga('article_right_middle');</script> <div class="ult_ztbox"> <h4>猜你喜欢</h4> <ul class="telist_rb clearfix"> <script>get_detail_right('wz_right_love',33,'')</script> </ul> </div> <script>keji_detail_ga('article_right_new_bottom');</script> <div class="ult_ztbox"> <h4>热门推荐</h4> <ul class="tvideo_r_b clearfix"> <script>get_detail_right('wz_right_hot',33,'')</script> </ul> </div> <script>keji_detail_ga('article_right_bottom');</script> </div> <!--右侧专题 end--> <div style="display:none"><a href="https://www.xyx234.com/wzztf/av/avdsah/">专题</a> </div> </div> </div> <script src="https://js.51dongshi.com/plug/qrcode/qrcode.min.js"></script> <script src="https://js.51dongshi.com/js/share.js" charset="UTF-8"></script> <script type="text/javascript" src="https://js.51dongshi.com/tpl/pc2/js/waypoints.min.js"></script> <script type="text/javascript" src="https://js.51dongshi.com/tpl/pc2/js/icon_step.js"></script> <style> #qrcode{padding: 15px;background: #fff;} </style> <div id="qrcode" style="display: none"></div> <script>new QRCode(document.getElementById("qrcode"), "https://m.xyx234.com/eedfavdsah.html");</script> <iframe src="https://hits.51dongshi.com/?biao=ho_article&id=972395" border="0" frameborder="0" style="width: 0px; height: 0px"></iframe> <script src="https://js.51dongshi.com/js/shHighlighter.js"></script> <link rel="stylesheet" href="https://jss.51dongshi.com/js/fffz/css/box.css"> <script id="fffz" data-domain="//www.xyx234.com/index" src="https://js.51dongshi.com/js/fffz/fffz.js"></script> <script type="text/javascript" src="https://jss.51dongshi.com/pcwz/tj.js"></script> <div style="display:none"><script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?4b1ebb0298b66c8a109db070c4878833"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </div> <!--foot star--> <div class="footer"> <div class="m_box"> <div class="footer_in"> <a href="#" target="_blank">产品服务</a> <a href="#" target="_blank">发展历程</a> <a href="#" target="_blank">企业资讯</a> <a href="#" target="_blank">企业文化</a> <a href="#" target="_blank">关于我们</a> <a href="#" target="_blank">加入我们</a> <a href="#" target="_blank">联系我们</a> <a href="#" target="_blank">网站导航</a> <a href="#" target="_blank">网站律师</a> </div> <ul class="ftrlist"> <li> <a rel="nofollow" href="https://www.itrust.org.cn" target="_blank"> <img src="https://js.51dongshi.com/tpl/pc2/images/footer_logo01.gif" alt="中国互联网协会"></a> </li> <li> <a rel="nofollow" href="https://www.12377.cn/" target="_blank"> <img src="https://js.51dongshi.com/tpl/pc2/images/12377logo.png" alt="中国互联网举报中心"></a> </li> <li> <a rel="nofollow" href="http://www.cyberpolice.cn/" target="_blank"> <img src="https://js.51dongshi.com/tpl/pc2/images/footer_logo05.gif" alt="网络110报警服务"></a> </li> <li> <a rel="nofollow" href="http://www.creditchina.gov.cn/" target="_blank"> <img src="https://js.51dongshi.com/tpl/pc2/images/creditchina.gif" alt="信用中国"></a> </li> <li class="last"> <a rel="nofollow" href="http://www.shdf.gov.cn/shdf/channels/740.html" target="_blank"> <img src="https://js.51dongshi.com/tpl/pc2/images/footer_logo11.png" alt="中国扫黄打非网"><p>中国扫黄打非网</p> </a> </li> </ul> <div class="footer_co"> <a href="/" class="footlogo"><img src="https://js.51dongshi.com/tpl/pc2/images/logo_bottom.png" alt="懂视"></a> <p>Copyright © 2019-2024 <a href="/" target="_blank">51dongshi.com</a> 版权所有</p> <p> <a rel="nofollow" target="_blank" href="https://beian.miit.gov.cn/">赣ICP备2023002352号-2</a> </p> <p>违法及侵权请联系:TEL:177 7030 7066 E-MAIL:11247931@qq.com 本站由北京市万商天勤律师事务所王兴未律师提供法律服务</p> </div> </div> </div> <!--foot end--> <a href="#0" class="cd-top">Top</a> <script type="text/javascript"> $(function(){ var _line=parseInt($(window).height()/3); $(window).scroll(function(){ if ($(window).scrollTop()>100) { $('.edu_top').css({'position':'fixed','top':'0','z-index':'99'}) }else{ $('.edu_top').css({'position':'relative','top':'0'}) } }) }) </script> <script type="text/javascript" src="https://jss.51dongshi.com/ga/all.js"></script> <div style="display:none"> <script type="text/javascript" src="https://s9.cnzz.com/z_stat.php?id=1278135046&web_id=1278135046"></script><script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?70ec0a2c78df5a4a3d49e475e943ceb6"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script><script> (function(){ var src = (document.location.protocol == "http:") ? "https://js.passport.qihucdn.com/11.0.1.js?d1f620a645f12a1c5b0bbce7b998d51e":"https://jspassport.ssl.qhimg.com/11.0.1.js?d1f620a645f12a1c5b0bbce7b998d51e"; document.write('<script src="' + src + '" id="sozz"><\/script>'); })(); </script></div> </body> </html>