Here is the magic to close a modal dialog browser window 
from a link in that window - or in various other ways.

I've only tested this on an IE5.01SP2 client under W2KSP2.
If anyone can validate other clients that would be nice.

As correctly suggested by others on this list you need an 
attribute of  onClick="window.close()".

This may be applied to a link, a paragraph, a div, or even 
to the whole body.  But, and here is the catch, if you 
apply it to a link the link still does its thing.  In fact 
that is true for any object with a default onClick action 
- the default action still occurs after the custom script.  

The way to defeat the default action is to return false 
from the custom onClick script.  The attribute we need is
onClick="window.close();window.event.returnValue=false".

Below please find a minimalist html file which will demo
these possibilities.  Cut and paste it and save it as 
SMD_target.htm.  Below that is another minimalist html 
file to invoke the first one - this shows how to dispense  
with links and buttons in general if that is your desire.

Hope this helps,
Duncan Fenton

=============================
<HTML>
<HEAD>
<TITLE>Modal Dialog Box</TITLE>
</HEAD>
<BODY onclick="if (window.event.shiftKey) window.close()">
<H1>Modal Dialog Box</H1>
<HR>
<P><A href="nowhere.htm" 
        onClick="window.close();window.event.returnValue = false">
        Click on this link to close window</A></P>
<BR>
<P onClick="window.close()">
        Or click on this paragraph to close window</P>
<BR>
<P>Or shift-click anywhere in the window to close it</P>
</BODY>
</HTML>
=============================
<HTML>
<HEAD>
<TITLE>showModalDialog Request</TITLE>
</HEAD>
<BODY>
<H1>showModalDialog Request</H1>
<P>Who needs buttons? Click 
  <NOBR onclick="window.showModalDialog('SMD_target.htm')">here</NOBR> 
  for Modal Dialog<BR>(You have to click the actual word 'here')</P>
</BODY>
</HTML>
=============================


=======Original Message=====
From: Aidan Whitehall [mailto:[EMAIL PROTECTED]
Sent: 16 October 2003 16:45
To: [EMAIL PROTECTED]
Subject: RE: [ cf-dev ] OT: JavaScript & modal dialogs


> That may not be too useful... I just tried it and it closed the PARENT
> before zipping the child (which stopped being modal) to the link.
> Feature or bug?
> 
> What behaviour are you trying to have, anyway?

The content of the modal window is explanatory information. It could be
done using a second browser window, but I love the functionality of the
modal window.

In the end, I couldn't get the syntax of the hyperlink to work, so said
"To hell with it" and just used a button.

It works, so it's what they're getting    ;-)


-- 
Aidan Whitehall <mailto:[EMAIL PROTECTED]>
Macromedia ColdFusion Developer
Fairbanks Environmental Ltd  +44 (0)1695 51775
Queen's Awards Winner 2003 <http://www.fairbanks.co.uk/go/awards>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]



-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to