Re: Javascript Style Properties for Dynamic Images in Safari
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Javascript Style Properties for Dynamic Images in Safari

From: Joe <jcox@kornet.net>
Date: Fri Mar 31 2006 - 16:00:31 CEST

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

"RobG" <rgqld@iinet.net.au> wrote in message
news:442d290d$0$2162$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> Joe Cox wrote:
>> 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().
>
> [...]
>
> --
> Rob
Received on Mon May 1 04:34:12 2006