Resizing an image using Javascript running in Opera Browser -


i hope can quirky issue having opera browser, have version 11 beta installed, suspect common problem in opera.

the website , page in question http://www.amigaos.net/index.html.

at bottom of body of html have following code resizes 3 images see on webpage depending on width of viewport @ page load. in safari , firefox code works fine, in opera following lines involve resizing width , height of image not work:

document.getelementbyid('img1').width = '475'; document.getelementbyid('img1').height = '375'; 

here code in full (sorry, layout, stackoverflow hasn't formatted carriage returns correctly)

<script type="text/javascript">  function getwidth()  {    var x = 0;    if (typeof window.innerwidth != 'undefined')    {      x = window.innerwidth;    }    else if (document.documentelement && document.documentelement.clientheight)    {      x = document.documentelement.clientwidth;    }    else if (document.body)    {      x = document.getelementsbytagname('body')[0].clientwidth;    }    return x;  }   width = getwidth();   if (width>=1680)  {   document.getelementbyid('img1').width = '475';   document.getelementbyid('img1').height = '375';   document.getelementbyid('img2').width = '475';   document.getelementbyid('img2').height = '375';   document.getelementbyid('img3').width = '475';   document.getelementbyid('img3').height = '375';  }  else if ((width>800) && (width<=1280))  {   document.getelementbyid('img1').width = '300';   document.getelementbyid('img1').height = '235';   document.getelementbyid('img2').width = '300';   document.getelementbyid('img2').height = '235';   document.getelementbyid('img3').width = '300';   document.getelementbyid('img3').height = '235';  }  else if (width<=800)  {   document.getelementbyid('img1').width = '225';   document.getelementbyid('img1').height = '195';   document.getelementbyid('img2').width = '225';   document.getelementbyid('img2').height = '195';   document.getelementbyid('img3').width = '225';   document.getelementbyid('img3').height = '195';  } </script> 

instead of doing width , height attributes, think can set width: 33% via css , have scaling happen automatically, regardless of browser window size. better solution trying use javascript, imho.

here's simple tutorial: http://haslayout.net/css-tuts/css-proportional-image-scale


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -