Link to home
Start Free TrialLog in
Avatar of d_jedi
d_jedi

asked on

*Real* modal windows

I would like to know how to create a pop-up window that does not lose focus to the opener page (ie. a modal window - like an alert or confirm box).

How can I do this without using a signed script?

NOTE: pls. don't respond with:
<BODY onBlur="window.focus()">

because this DOES NOT work.  Just try right clicking on the parent window, and then anywhere else (not one of the context menu options) in the parent.
Avatar of a.marsh
a.marsh

Does it need to be cross-browser?

And what is the content of the popup page? Does it have any form elements?

:o)

Ant
ASKER CERTIFIED SOLUTION
Avatar of a.marsh
a.marsh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want an IE only solution you can use

window.showModalDialog("filename")
Avatar of d_jedi

ASKER

Ant:

Unfortunately, your code does not work fully.

With the parent window behind the child, it is possible (by randomly, repeatedly clicking in the parent window) to hide the child.

This is the same problem (albeit it is slightly better than what I had) using just <body onblur="focus()">
Avatar of d_jedi

ASKER

Unfortunately, the application I am developing needs to work with both IE5 and NS6

(damn Netscape!!  I HATE Netscape!!)
In IE or Netscape....the code isn't just for the popup, it is also for the parent - try it out at my demo site:

http://www.btinternet.com/~ant.marsh/ee/on_top_focus_parent.html


Here is the code again (I've made 1 small change):

on_top_focus_parent.html
------------------------


<html>
<head>
<script language="javascript">
<!--

newwin = window.open("on_top_focus_child.html", "newwin", "width=200,height=200");

//-->
</script>
</head>
<body onFocus="if(!newwin.closed){ newwin.focus(); }" onBlur="if(!newwin.closed){ newwin.focus(); }">
</body>
</html>


on_top_focus_child.html
-----------------------

<html>
<head>
</head>
<body onFocus="window.opener.blur()">
<form>
<select name="mySelect">
<option value="">test</option>
<option value="">test</option>
<option value="">test</option>
</select>
</form>
</body>
</html>


I've tested it in IE5.5 and Netscape 4.7 and it works fine.

:o)

Ant
Avatar of d_jedi

ASKER

Ant:  

again, close - but no cigar.

Through random, quick clicking, the parent window can be brought back into focus (this is not good)

Perhaps, if the child window is open,
any event in the parent window could cause the child window to gain focus.

(don't know really how to do this - but the algorithm's there :->)
mmmm...nice idea, but you are going to have "fun and games" trying to get it to br cross-browser - I've played with this before and particularly in Netscape just get stuck in infinite loops!

Ant
Is it only IE where you can "randomly" get focus back to the parent?

I can't replicate that at all! It works fine in both browsers on my machine.

Ant
Avatar of d_jedi

ASKER

It is only IE that I tried it with, but by quick, random clicks, I can eventually have the focus move to the parent window.

The comp. I'm doing this on has a 1 GHz Athlon processor, 256 MB RAM, running Windows 2000 Advanced Server and IE 5.5, if you would like to know this for comparison.

I just tested it in Netscape (6) - and it doesn't work @ all!
I haven't tried in Netscape 6 - it doesn't surprise me that it doesn't work though!

I suppose I should try and download Netscape 6 to my machine....

I'll see if I can improve thigns further....but ultimately you are not going to get a 100% working cross-browser solution...

:o\

Ant
d_jedi, at the end of the day you are not going to get 100% working cross-browser solution.....it's just not going to happen I'm afraid.

Here are some useful articles for you to look at:

http://developer.netscape.com/viewsource/goodman_modal/goodman_modal.html

http://www.devguru.com/features/knowledge_base/A100203.html

http://www.faqts.com/knowledge_base/view.phtml/aid/844/fid/124

http://www.webreference.com/js/tutorial1/dialog.html


I think you'll find the first 3 links particularly useful.

:o)

Ant
Avatar of d_jedi

ASKER

If mouse clicks could be disabled (left and right) in the main form when the child is shown, then I think we might have a final solution..
Avatar of Asta Cu
Please update the expert here who have so willingly stepped in to help you, since much time has passed since your last comments, and Email notifications may not have been generated to the participating experts here due to some problems at that time.  If you've been helped, accept the respective question by that expert to grade and close it.

Somewhat off-topic, but important.

****************************** ALERT********************************
WindowsUpdate - Critical Update alert March 28, 2002 from Microsoft
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/bulletin/ms02-015.asp
Synopsis:
Microsoft Security Bulletin MS02-015  
28 March 2002 Cumulative Patch for Internet Explorer
Originally posted: March 28, 2002
Summary
Who should read this bulletin: Customers using Microsoft® Internet Explorer
Impact of vulnerability: Two vulnerabilities, the most serious of which would allow script to run in the Local Computer Zone.
Maximum Severity Rating: Critical
Recommendation: Consumers using the affected version of IE should install the patch immediately.
Affected Software:
Microsoft Internet Explorer 5.01
Microsoft Internet Explorer 5.5
Microsoft Internet Explorer 6.0

Thought you'd appreciate knowing this.
":0)
Asta
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> You cannot delete a question with comments, special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process for further information, if needed.  https://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.  Anytime you have questions which are LOCKED with a Proposed Answer but does not serve your needs, please reject it and add comments as to why.  In addition, when you do grade the question, if the grade is less than an A, please add a comment as to why.  This helps all involved, as well as future persons who may access this item in the future to seek help.

To view your open questions, please click the following link(s) and keep them all current with updates.
https://www.experts-exchange.com/questions/Q.20121834.html
https://www.experts-exchange.com/questions/Q.20155547.html
https://www.experts-exchange.com/questions/Q.20155541.html
https://www.experts-exchange.com/questions/Q.20166098.html
https://www.experts-exchange.com/questions/Q.20172358.html
https://www.experts-exchange.com/questions/Q.20173609.html
https://www.experts-exchange.com/questions/Q.20242805.html
https://www.experts-exchange.com/questions/Q.20273496.html




PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643

Moderators will finalize this question if still open in 7 days, by either moving this to the PAQ (Previously Asked Questions) at zero points, deleting it or awarding expert(s) when recommendations are made, or an independent determination can be made.  Expert input is always appreciated to determine the fair outcome.
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange
Zero response, finalized by Moondancer - EE Moderator