iframe调用父页面函数示例详解

window.parent.xxxxx();//xxxxx()代表父页面方法

具体列子如下,其中包括easyUI的右键和单击事件

parent.jsp

body部分代码

<body> <!-- 左侧目录 --> <div data-options="region:'west',split:true,title:'主题',iconCls:'icon-arrowIn'"> <!-- 目录数 --> <ul></ul> </div> <input type="hidden" value="${param.type }"/> <!-- 右侧窗体 --> <div data-options="region:'center',title:'内容显示',iconCls:'icon-arrowOut'"> <iframe src="" frameborder="0"></iframe> </div> <!-- 右键菜单 --> <div id=rightCliMean> <div data-options="iconCls:'icon-edit'" >修改</div> <div 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(); })

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgpwdy.html