Solved

*Real* modal windows

Posted on 2001-07-23
16
327 Views
Last Modified: 2011-08-18
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.
0
Comment
Question by:d_jedi
  • 7
  • 5
  • 2
  • +2
16 Comments
 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
Does it need to be cross-browser?

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

:o)

Ant
0
 
LVL 15

Accepted Solution

by:
a.marsh earned 200 total points
Comment Utility
This will work in both browsers:

on_top_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(); }
else { self.focus(); }">
</body>
</html>
on_top_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>


Although you will find an issue with form elements in Netscape.

:o)

Ant
0
 
LVL 5

Expert Comment

by:nilapenn
Comment Utility
If you want an IE only solution you can use

window.showModalDialog("filename")
0
 

Author Comment

by:d_jedi
Comment Utility
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()">
0
 

Author Comment

by:d_jedi
Comment Utility
Unfortunately, the application I am developing needs to work with both IE5 and NS6

(damn Netscape!!  I HATE Netscape!!)
0
 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
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
0
 

Author Comment

by:d_jedi
Comment Utility
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 :->)
0
 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
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
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
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
0
 

Author Comment

by:d_jedi
Comment Utility
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!
0
 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
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
0
 
LVL 15

Expert Comment

by:a.marsh
Comment Utility
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
0
 

Author Comment

by:d_jedi
Comment Utility
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..
0
 
LVL 27

Expert Comment

by:Asta Cu
Comment Utility
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
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
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.
http://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.  http://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.
http://www.experts-exchange.com/questions/Q.20121834.html
http://www.experts-exchange.com/questions/Q.20155547.html
http://www.experts-exchange.com/questions/Q.20155541.html
http://www.experts-exchange.com/questions/Q.20166098.html
http://www.experts-exchange.com/questions/Q.20172358.html
http://www.experts-exchange.com/questions/Q.20173609.html
http://www.experts-exchange.com/questions/Q.20242805.html
http://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 http://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
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Zero response, finalized by Moondancer - EE Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now