2014年6月26日 星期四

[JQuery] Block parent window when popup the child window




Top frame


<head>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/blockUI.js"></script>
</head>
<script language="javascript">
<!--
function blockUI() {
$
.blockUI({ message: null });
}

function unblockUI() {
$
.unblockUI();
}
-->
</script>

HTML



<div>
<iframe id="myframe"></iframe>
</div>




Second frame


<script language="javascript">
<!--
function AddDevice(content)
{
window
.open( content ,'PopupWindow','resizable=yes,scrollbars=yes,width=740,height=600,top=20,left=100');
top
.blockUI();
}
-->
</script>



<button id="DHCPBtn" onclick="AddDevice('../a.htm');">DHCP</button>




Popup window


When user click the DHCPBtn button of second frame, then popup the window. After setting, user press the close button.



<button class="button floatright" onClick="window.opener.top.unblockUI();self.close();" type="button">Close</button>

The funcion will call function unblockUI of first frame.


Reference



  1. [Javascript] Call top frame function by using javascript


0 意見:

張貼留言