时间:2021-05-28
window.parent.xxxxx();//xxxxx()代表父页面方法
具体列子如下,其中包括easyUI的右键和单击事件
parent.jsp
body部分代码
<body class="easyui-layout"> <!-- 左侧目录 --> <div data-options="region:'west',split:true,title:'主题',iconCls:'icon-arrowIn'" style="width: 270px; background: #efefef"> <!-- 目录数 --> <ul id="tree" class="easyui-tree"></ul> </div> <input type="hidden" value="${param.type }" id="themeType"/> <!-- 右侧窗体 --> <div data-options="region:'center',title:'内容显示',iconCls:'icon-arrowOut'" style="overflow: hidden"> <iframe name="leftIframe" id="leftIframe" src="" frameborder="0" height="100%" width="100%"></iframe> </div> <!-- 右键菜单 --> <div id=rightCliMean class="easyui-menu" style="width:120px;"> <div onclick="updateTheme();" data-options="iconCls:'icon-edit'" >修改</div> <div onclick="removeObjectNode();" data-options="iconCls:'icon-tip'" >删除</div> </div> <script type="text/javascript"> loadTree(); </script> </body>js部分:
function loadTree() { $('#tree').tree( { url : 'xxxxx.action, animate : true, lines : true, onContextMenu : function(e, node) { e.preventDefault(); $(this).tree('select', node.target); /** * 不可以对根节点(默认主题)进行操作 */ var parent = $(this).tree('getParent',node.target); if(parent){ if(node.text == '默认主题'){ $.messager.alert("提示信息","默认主题不能进行操作!","warning"); return false; } $('#rightCliMean').menu('show',{ left: e.pageX, top: e.pageY }); } }, onClick:function(node) {//单机事件 var type = node.attributes.type; if("Schema" == type){ var themeType = $("#themeType").val(); $('#leftIframe').attr('src', 'xxxx.action'); return; } } }); } child.jsp/** * 刷新左侧主题 */ $(function(){ window.parent.loadTree(); })声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
1、iframe子页面调用父页面js函数子页面调用父页面函数只需要写上window.praent就可以了。比如调用a()函数,就写成:复制代码代码如下:wind
本文实例讲述了js中iframe调用父页面的方法。分享给大家供大家参考。具体实现方法如下:子页面调用父页面的方法在js中很容易实现。我们只需要在主页面加个函数,
1)在iframe中查找父页面元素的方法:$('#id',window.parent.document)2)在iframe中调用父页面中定义的方法和变量:par
一、在iframe中查找父页面元素的方法:$(‘#id',window.parent.document)二、在iframe中调用父页面中定义的方法和变量:par
在做项目时,遇到了操作iframe的相关问题。业务很简单,其实就是在操作iframe内部某个窗体时,调用父窗体的一个函数。于是就写了两个很简单的htm页面用来测