Forum Moderators: open

Message Too Old, No Replies

NS/FireFox equiv of event.srcElement

src attraibute of an image via event

         

MorningZ

11:40 am on Aug 7, 2004 (gmt 0)

10+ Year Member



Long story short, i did a js function that goes through all the images on a page and, if over a width, will resize the image to acceptable width and attach an "onClick" event that'll open the un-resized image in a new window

in IE, its simply this (code before guarentees the object is an image):

img.onclick = function (e) {window.open(window.event.srcElement.src)}

i for the life of me can't find the NS/FireFox/Mozilla equiv of "window.event.srcElement.src", i am just currently saying:

img.onclick = function (e) {alert('Image Resized to ' + MaxWidth + ' pixels')}

i'd like it to work with non-IE if someone could point me how i can get the "src" attribute of the image

- Thanks in advance

RonPK

12:55 pm on Aug 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



target is your friend.

img.onclick = function (e) { 
if (window.event) e = window.event;
var srcEl = e.srcElement? e.srcElement : e.target;
// srcEl now can be used x-browser.
// (rest of the script here)
}

MorningZ

6:13 pm on Aug 7, 2004 (gmt 0)

10+ Year Member



thank you so much!

works like a charm