[thelist] JS/DOM: Image doesn't load in remote window

Frank lists at frankmarion.com
Wed Jul 14 17:06:12 CDT 2004


I have a page containing a table full of images. One image per cell. 
Each  cell calls the following function as such.

         <td onclick="propImgView(this);">

I can certainly load just the image in a new window, but I want some HTML 
to format things a bit, remove padding and margins in the window.

The function retrieves the image properties (they are full 640x480 images 
resized by the browser --I know not good). It then opens a new window, and 
should create an image object and assign it the same source as the one 
retrieved from the table cell (view 'larger' image).

For some reason, though, I can't seem to get the bugger to display. Using 
alert() I know that the src is correct, and it's a full url, not 
relative.  The remote document contains the skeleton of an html page. No 
content in the body (not even a space). It does include meta tags, and 
styles, but that should be irrelevant.

I keep going over this and can't figure out where my error might be. Can 
someone spot it?

-----------
function propImgView(obj) {

         // Get the source
         image = obj.childNodes.item(0).src

         // Make, open and load the window
         win_props = 
'toolbar=no,location=no,directories=no,status=no,menubar=no,' +
                                 'scrollbars=no,resizable=yes,width=640,height=480,top=25,left=25';

         remote = 
window.open("../properties/property_popup.html",'remote',win_props);

         // Create an image object in the remote window, set it's id and source
         r = remote.document.createElement("img");
         r.setAttribute("src",image);
         r.setAttribute("id","full_image");

         // Append it to the remote window's body
         b = remote.document.getElementsByTagName("body").item(0);
         b.appendChild(r);  // IE chokes on this. Why? Is this my problem 
with FireFox too?

         // Test
         alert(b.innerHTML)
}
-----------


--
Frank Marion     lists at frankmarion.com      Keep the signal high.





More information about the thelist mailing list