Close child popup preview window when parent becomes focus window again

Posted on 2003-03-18
Medium Priority
Last Modified: 2007-12-19

I am having some trouble. I have looked at onBlur commands and there are errors between Mac IE 5 and Windows IE.

What I have is a parent page of thumbnail pictures. Each picture has a url to spawn a larger child 'Detail' preview.

<!-- Script used in parent window to spawn child -->
<script language="JavaScript">
function MM_openBrWindow(theURL,winName,features) { //v2.0

This is what I am using as the link on the page to get my larger preview window. I use the window name 'Detail' for all of them.

<a href="javascript:;" onMouseDown="MM_openBrWindow('images/landscape/1138.htm','Detail','scrollbars=yes,width=580,height=600,dependent=yes')"><img vspace="10" hspace="10" src="images/landscape/thumbs/1138.jpg" border="0"></a>

In the larger Detail window a large image is displayed with previous and next links. The user will click on these if they wish to cycle through images. What I want though is when the user clicks back on the parent thumb window that the child detail window is closed.

I tried a close from the child window when a onblur was triggered in the body tag but this would trigger even if the user clicks anywhere within the detail window eg the previous and next links.

Anythoughts to getting round this?
Question by:imac_jim
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 8164077
try this
 use different picture to this code
replace all the image in the code

 <SCRIPT LANGUAGE="javascript">

<!-- hide from none JavaScript Browsers              

Image1 = new Image(265,406)
Image1.src = "ep.gif"

Image2 = new Image(265,406)
Image2.src = "3.gif"

Image3 = new Image(265,406)
Image3.src = "4.gif"                                        

Image4 = new Image(265,406)
Image4.src = "1.gif"                                        

Image5 = new Image(265,406)
Image5.src = "2.gif"                                        

Image6 = new Image(265,406)
Image6.src = "5.gif"                                        

Image7 = new Image(265,406)
Image7.src = "6.gif"                                        
Image8 = new Image(265,406)
Image8.src = "7.gif"                                        

function zoomin() {
document.emp.src = Image3.src; return true;

function zoomout() {
document.emp.src = Image2.src; return true;

function original() {
document.emp.src = Image1.src; return true;

function o() {
document.emp.src = Image4.src; return true;

function p() {
document.emp.src = Image5.src; return true;

function i() {
document.emp.src = Image7.src; return true;


// - stop hiding -->

<IMG NAME="emp" SRC="ep.gif" USEMAP="#ep">

<MAP NAME="ep">
<AREA SHAPE="RECT" COORDS="369, 84, 396, 119" NOHREF >
<AREA SHAPE="RECT" COORDS="313, 32, 336, 62" NOHREF >
<AREA SHAPE="RECT" COORDS="272, 43, 300, 69" NOHREF >
<AREA SHAPE="RECT" COORDS="275, 96, 302, 126" NOHREF onMouseOver="i()"  onMouseOut="original()">
<AREA SHAPE="RECT" COORDS="220, 82, 248, 111" NOHREF onMouseOver="zoomin()" onMouseOut="original()">
<AREA SHAPE="RECT" COORDS="127, 80, 154, 109" NOHREF onMouseOver="p()" onMouseOut="original()">
<AREA SHAPE="RECT" COORDS="17, 96, 45, 125" NOHREF onMouseOver="zoomout()" onMouseOut="original()">
<AREA SHAPE="RECT" COORDS="59, 31, 82, 58" NOHREF onMouseOver="o()" onMouseOut="original()">

<AREA SHAPE="default" nohref>


LVL 46

Accepted Solution

fritz_the_blank earned 200 total points
ID: 8166768
If you use:

var winChild

function openWindow(){
   winChild = window.open(//add your parameters here)
function closeChild(){

<body onFocus="closeChild()">

that will close the child window when the parent gets focus.

Fritz the Blank

Author Comment

ID: 8170384
Thanks for your help! I have tested it and at this stage works fine cross platform.
LVL 46

Expert Comment

ID: 8170408
Glad to have helped,

Fritz the Blank

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…

764 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