在主页面上有两个Iframe 页面,一个iframe B中触发一个按钮可以刷新两外一个iframe A
主页面中关于A页面
<div class="i-region-content" id="result_events"> <iframe src="xxxx/XXX" height="100%" width="100%" frameborder="0" scrolling="no" id="iframe_result_event" ></iframe> </div>
主页面中关于B页面
<div class="i-region-content"> <iframe src="yyyy/YYYYY" height="100%" width="100%" frameborder="0" scrolling="no"></iframe> </div>
在B页面所对应的js中按钮事件可以这么写
function toRepair(deviceId){ //刷新主页面 parent.iframe_result_event.location.reload(); //获取主页面中的某个值 //var t = window.parent.document.getElementById("current_deviceId").value; //调用iframe A 中的方法 parent.iframe_result_event.contentWindow.getInfo(deviceId) }
其中 iframe_result_event为iframe A的名字 getInfo为 iframe A中的一个方法
在A页面中具体方法如下
function getInfo(deviceId) { //刷新Iframe A页面 parent.iframe_result_event.contentWindow.location='/xxxxx?objectId=' + deviceId }
另还有个思路可以考虑在页面跳转的场景下使用
在主页面中放一个隐藏域,在跳转前的B页面按钮点击的时候修改隐藏域的值,然后跳转后的A页面读取这个隐藏域的值,然后去处理相关的事情(也可以在主页面的隐藏域中加个监听事件)
更多内容参考https://www.cnblogs.com/BlingSun/p/7484237.html