I am currently working on the main feature scheduled for version 1.3 of activeRenderer: the inclusion of images, defined as jpg, gif or png link attributes, into the outline's web page. Following is a rather technical description of the problems I'm experiencing doing this in Javascript.
I'm creating an image type element in an HTML 4.01 page with
var includedImg = document.createElement ('img');
I'm setting various attributes, then loading this image from an outside source, defined in the 'url' string :
includedImg.src = url;
At this point, I need to consider some image resizing options before appending this image into the page by using :
expandedNode.appendChild (includedImg);
The resizing decision depends on 2 factors :
- The width of the image I've loaded into IncludedImg.
- The width of the containing 'div' element defined by expandedNode.
First, to find the width of the image, I tried :
includedImg.getAttribute ('width');
Understandably, this only returns a non 'null' value if and when the actual image file is loaded into the browser's cache.
My first problem is that I do not currently know a standard, cross browser method of finding out whether the image is fully loaded before querying its width attribute.
Second, to find the width of the containing div, I relied on the abstract view model as defined by the W3C :
document.defaultView.getComputedStyle (expandedNode, '').getPropertyValue('width');
This works fine with all versions of Mozilla. Unfortunately, Microsoft
Internet Explorer relies on a different, proprietary model, using the
currentStyle property of the element. So I tried something like this when
testing for MSIE :
expandedNode.currentStyle.width;
This returns 'null' with MacOS X MSIE 5, and a disconcerting 'auto' string with Windows MSIE 5/6.
So my second issue is finding a way to properly use the currentStyle property, or any other relevant property, to retrieve this elusive width information with MSIE.
If anyone reading this has a clue, I'd appreciate some feedback.