
March 8th, 2005, 03:38 AM
|
 |
Moderator From Beyond
|
|
Join Date: Sep 2004
Location: Israel
|
|
Dialog Window for non IE browsers (JavaScript)
simple way to force focus to the child window.
Code:
<script type="text/javascript" language="javascript">
var activeDialog=0;
//OpenDialog: opens given URL as dialog window - focus can't be set on parent until child is closed.
function OpenDialog(strURL, properties)
{
//maybe we have IE?
if (typeof window.showModalDialog != "undefined") {
window.showModalDialog(strURL);
return true;
}
//non IE browser
window.onfocus = WindowFocus;
activeDialog = window.open(strURL, "dialog", properties);
return true;
}
function WindowFocus(event)
{
if (activeDialog) {
try {
activeDialog.focus();
}
catch (e) {
activeDialog = 0;
}
}
}
</script>
to use this code, simply call the OpenDialog function passing the desired url and window properties (position, dimensions etc) for example:
Code:
<input type="button" value="Open as dialog" onclick="OpenDialog('MyPage.html', 'width=500,height=300');" />
|