if (myFrame.attachEvent) {
myFrame.attachEvent("onload", function () {
alert("兼容IE加载的加载方法");
});
} else {
myFrame.onload = function () {
alert("兼容其他浏览器加载方法");
};
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<div>我是父窗口内容</div>
<div><input type="button" id="btnFather" value="调用子窗口方法" /></div>
<br />
<br />
<br />
<iframe id='myFrame' name="myFrame" src="FChild.html" width='100%' height='100%' frameborder='0'></iframe>
<script type="text/javascript">
document.getElementById("btnFather").onclick=function () {
myFrame.window.sonMethod();
}
function fatherMethod() {
alert("父窗口方法!");
}
if (myFrame.attachEvent) {
myFrame.attachEvent("onload", function () {
alert("兼容IE加载的加载方法");
});
} else {
myFrame.onload = function () {
alert("兼容其他浏览器加载方法");
};
}
</script>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<div style="border:1px solid red;"> 我是子窗体内容</div>
<div > <input type="button" id="btnSon" value="调用父窗口方法" /></div>
<script type="text/javascript">
document.getElementById("btnSon").onclick = function () {
parent.fatherMethod();
}
function sonMethod() {
alert("子窗口方法!");
}
</script>
</body>
</html>
<div id="divRoleUsers" title="设置用户角色" class="easyui-window" closed="true" collapsible="false" minimizable="false" maximizable="false" style="width: 140px; height: 250px; padding: 5px;">
</div>
<div > <input type="button" id="btn" value="设置用户角色" /></div>
<script type="text/javascript">
$("#btn").click(function () {
showSetUserRoleWindow();
});
//设置用户角色
function showSetUserRoleWindow() {
var getSelections = $("#tt").datagrid("getSelections");
if (getSelections.length > 1 || getSelections.length == 0) {
$.messager.alert("错误提示", "请选中一行数据!", "error");
return false;
}
var data = getSelections[0]; //获取选中的一行所有json的数据
//if ($("#divRoleUsers #iframe").length != 0) {
// $("#divRoleUsers #iframe").remove();
//}
// $('#divRoleUsers').append("<iframe id='iframe' name='iframe' src='RoleUsers_Update.aspx?UserID=" + data.UserID + "' width='100%' height='100%' frameborder='0'></iframe>");
//错误做法!:上面src='RoleUsers_Update.aspx?UserID=" + data.UserID + "' 这里通过拼接参数iframe的src,
//然后通过子窗口 parent.document.getElementById("iframe").getAttribute("src");//获取父窗体iframe的src 发现根据获取不到UserID的值,为null,也是因为加载顺序先后的问题,导致我要用给iframe注册onload事件后才能获取到我需要的结果
//if (myframe.attachEvent) {
// myframe.attachEvent("onload", function () {
// alert("Local iframe is now loaded.");
// myframe.window.loadAllRole();
// });
//} else {
// myframe.onload = function () {
// alert("Local iframe is now loaded.");
// myframe.window.loadAllRole();
// };
//}
if ($("#divRoleUsers #myframe").length != 0) { //这一步是必须的!!!,因为不加这一句下面onload绑定事件只执行一次,我需要每次加载完iframe都调用一次子窗口的方法!
$("#divRoleUsers #myframe").remove();
}
$('#divRoleUsers').append("<iframe id='myframe' name='myframe' src='RoleUsers_Update.aspx' width='100%' height='100%' frameborder='0'></iframe>");
if (myframe.attachEvent) {
myframe.attachEvent("onload", function () {
myframe.window.loadAllRole();
myframe.window.loadUserRole(data.UserID);
});
} else {
myframe.onload = function () {
myframe.window.loadAllRole(); //调用子窗口iframe里面的方法加载所有的角色checkbox
myframe.window.loadUserRole(data.UserID); //接着传递用户ID过去给子窗口的方法,给用户拥有的角色设置checkbox选中
};
}
$('#divRoleUsers').window('open');
}
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有