PDA

View Full Version : a Modal popup window without using the showModalDialog?



codeexploiter
12-04-2006, 08:46 AM
Hi all,

Is it possible to create a modal popup window without using window.showModalDialog().

I have a parent window and a child window. I've generated a popup window using window.open() and using window.opener in the popup window.

I want to make the popup window modal, which has the focus one can't access the parent window without closing the child window.

thanks for the help

regards

jscheuer1
12-04-2006, 06:10 PM
It would be something like:


onblur=function(){self.focus();};

placed on the window that you do not want to have lose focus.

However, sounds like a bad idea as on the one hand, it is very hard to make these sorts of determinations for the user in all situations that could arise. On the other hand, if you just need an alert, a confirm or an input from the user, it would be more efficient and less risky to use one of these.

codeexploiter
12-05-2006, 03:42 AM
Thanks for the reply John.

I am working on a HTML preview feature so whatever changes/configurations set by the user can be viewed a preview before applying them.

So whenever the user clicks on preview button the preview window will popup and I don't want to allow users to access the main window (parent window) without closing the child (popup) window.

In IE using showModalDialog() it is possible but it is not working on firefox.

I am looking for something which is compatible in different browsers like IE and mozilla based ones (I am not forgetting Opera here :))

codeexploiter
12-06-2006, 06:31 AM
Found a way that involves enabling privileage on UniversalBrowserWrite that will give the user a dialog box whether they wish to allow this or not.

The following code will make a modal pop up in Firefox even in 2.0 version



netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");

winHandle = window.open("popup.html", ID, "modal,toolbar=false,location=false,directories=false,status=false,menubar=false,scrollbars=no,resizable=no,left="+left+",top="+top+",width="+width+",height="+height);
winHandle.focus();