resizing images in javascript for firefox

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
poizn
Forum Newbie
Posts: 17
Joined: Thu Jun 15, 2006 10:12 am
Location: Durban - Souht Africa

resizing images in javascript for firefox

Post by poizn »

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi all

I have a page with a bunch of images on it and need to resize all of them to fit nicely on the page in columns and rows. So i use javascript and when each images loads I call a function to resize them based on the screen width and height BUT it doesnt work in firefox!!!!

this is a basic run down version of the function
[syntax="javascript"]
function resize_img(evt) {
  if(!evt)
    evt = window.event;

  var src = evt.target || evt.srcElement;
  src.style.width = 100 + "px";
}
can anyone help PLEASE

thanks in advance


Pimptastic | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
poizn
Forum Newbie
Posts: 17
Joined: Thu Jun 15, 2006 10:12 am
Location: Durban - Souht Africa

Post by poizn »

I'm sorry if I get the whole tags things wrong (but i'll try :)) BUT I figured it out

Here is the new revised function (only took 2 days to find 1 small word)

Code: Select all

  function resize_img(evt) {
    if(!evt)
      evt = window.event;
    evt = evt.currentTarget || evt.srcElement;
    evt.style.width = 400 + "px";
  }
The only change here "target" becomes -> "currentTarget"

Thanks all hope this helps someone out there :)

feyd | mm, not so much figured it out. But at least it was in a

Code: Select all

tag.[/color]
Post Reply