[Javascript] Using the popup object in IE

Peter Brunone peter at brunone.com
Mon Jan 19 11:31:49 CST 2004


Matt,

	I have IE 6, and all of your code works just fine for me.

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of Matt Barton
Sent: Monday, January 19, 2004 11:10 AM
To: javascript at LaTech.edu
Subject: [Javascript] Using the popup object in IE


Hi,

This isn't purely a javascript problem this, more like dHTML as it
contains a deal of css.  Also, to make matters more evil, I'm only
concerned with finding a solution for IE5.5+ (not my descision - it was
made before I joined the company!).

What I'm trying to do is create a popup dHTML menu using the popup
object.  I have a popup window appearing and it's appearance is about
right (it's content is defined by setting its innerHTML property).  On
the window is a set of nested tables that describe a menu.  The problem
I am seeing is that I cannot seem to trigger calls to functions from the
event bound to the <td> objects.  For instance this will trigger an
alert box when you click the correct cell:

<table>
   <tr>
      <td onClick="alert ('Hello, World!')">Click me.</td>
   </tr>
</table>


However - this example will _not_ trigger an alert box....

<script language="javascript">
   function fShout (sMsg) {
      alert (sMsg);
   }
</script>
<table>
   <tr>
      <td onClick="fShout ('Hello, World!')">Click me.</td>
   </tr>
</table>

Strange, no?  I'm thinking that I've done something really basic and
dumb wrong, and I've been looking at it for so long that I just can't
see it.

Can anyone help?

Thanks,

Matt

Oh - in case you want to see how I'm creating and displaying the popup
object, this is an example of code:

   <IE:Download ID=dwn STYLE="behavior:url(#default#download)" />

   <SCRIPT>
      function onDone(src) {
         //oPopup.document.write(src);
         oPopup.document.body.innerHTML = src;
      }

      function showPopup(iX, iY) {
         oPopup.show(iX, iY, 300, 500, document.body);
      }
      var oPopup = window.createPopup();
      //The callback function pointer takes a single parameter. When a
file downloads successfully, the file contents are passed as the
parameter and are accessible in script.
      //startDownload is a member of the download default behavior.
      dwn.startDownload("popup_source3.html",onDone);
   </SCRIPT>
   <img src="menu.gif" onMouseOver="showPopup(event.clientX,
event.clientY);" style="cursor: hand">


----
Hovering over the image causes the popup to display.  The observant
amongst you will notice that most of the above code was, ahem, sourced
(robbed) from the M$ support site.  The example snippets of code that I
use to explain the problem would be included in the popup_source3.html
file which the browser downloads.





More information about the Javascript mailing list