Solved

*Real* modal windows

Posted on 2001-07-23
16
343 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
ID: 6309078
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
ID: 6309093
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
ID: 6310940
If you want an IE only solution you can use

window.showModalDialog("filename")
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:d_jedi
ID: 6314318
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
ID: 6314323
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
ID: 6314424
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
ID: 6317771
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
ID: 6321188
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
 
LVL 15

Expert Comment

by:a.marsh
ID: 6321190
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
ID: 6322677
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
ID: 6322972
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
ID: 6329754
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
ID: 6349199
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
ID: 6906992
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
ID: 6918331
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
ID: 7084639
Zero response, finalized by Moondancer - EE Moderator
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tools for analysis of code 4 44
How to change the colour of columns using dynamic data for google charts 3 41
Use Mid in Html 6 21
DataTable column sorting incorrectly 2 17
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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

685 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