> I am having a problem with style properties for dynamic images in Mac OS X
> Safari. By dymanic images, I mean images allocated with the javascript 'new
> Image()' call.
new Image() is not W3C DOM compliant, though I guess it's DOM 0. It seems
Safari creates an image object, but errors when you try to do anything with
it. Use W3C document.createElement() instead.
[...]
> function makeImgs(){
> var container1 = document.getElementById('cont1');
> var container2 = document.getElementById('cont2');
> var img1 = new Image(150,130);
Replace with:
var img1 = document.createElement('img');
img1.style.height = '150px';
img1.style.width = '130px';
> var img2 = new Image(150,130);
Replace as above with createElement().
[...]

Signature
Rob
Joe - 31 Mar 2006 15:00 GMT
Thanks. Actually, in the first version of my application I did use
document.createElement('img') statements. But, I read somewhere that if I
had many images I planned to swap out dynamically I could improve
performance by pre-caching from the server to the client with new Image()
calls. I guess this is not an option if I intend to support Safari browsers.
Trying to maintain cross browser compatibility is an extreme pain.
Thanks again.
Joe
>> I am having a problem with style properties for dynamic images in Mac OS
>> X Safari. By dymanic images, I mean images allocated with the javascript
[quoted text clipped - 22 lines]
>
> [...]
RobG - 31 Mar 2006 17:49 GMT
> Thanks. Actually, in the first version of my application I did use
> document.createElement('img') statements. But, I read somewhere that if I
> had many images I planned to swap out dynamically I could improve
> performance by pre-caching from the server to the client with new Image()
> calls. I guess this is not an option if I intend to support Safari browsers.
If you are doing this for caching, then there is no difference between new
Image and createElement('img') - both create a DOM image object and
assigning a src attribute will load the image.
> Trying to maintain cross browser compatibility is an extreme pain.
new Image is not a W3C method, so if you just use createElement you are
standards compliant and cross-browser. You might consider testing for
createElement and use new Image as a fall-back, but only if support for
version 4 browsers matters.
The W3C DOM HTML spec has a HTMLImageElement interface, but it only has
properties, not methods.
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-17701901>
[...]

Signature
Rob