Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

578 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