查看文章 |
用window.open()代替window.showModalDialog()
2008-08-27 17:36
来源:JavaEye 作者:ddh9504 模式窗口太过于局限性,所以我研究了一个完全可以用 window.open()代替window.showModalDialog()的方法,其资料贴在了下面: 有两个页面,一个是调用页面---main.html,一个是被调用页面---modalWindow.html HTML语言: main.html
<html>
<head> <script type="text/javascript"> newWin = null; function doOpen() { newWin = window.open('modalWindow.html','newWin','height=200,width=400,top=200,left=200,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no'); } window.onfocus = function() { if(newWin) { if(!newWin.closed) { newWin.focus(); } } } window.document.onfocus = function() { if(newWin) { if(!newWin.closed) { newWin.focus(); } } } window.document.onclick = function() { if(newWin) { if(!newWin.closed) { newWin.focus(); } } } window.document.ondblclick = function() { if(newWin) { if(!newWin.closed) { newWin.focus(); } } } </script> <title>main</title> </head> <body> <input type="button" value="Show me" onclick="doOpen();"> </body> </html>
************************************************************************************************************* ************************************************************************************************************* HTML语言: modalWindow.html <html>
<head> <title>modalWindow</title> </head> <body> sub window!!!! </body> </html> 在这个页面 modalWindow.html 中的方法可以调用父窗口的方法 其用法是 opener.functionName(param); |
最近读者: