[Javascript] Class and ID

Peter-Paul Koch gassinaumasis at hotmail.com
Wed Aug 1 02:41:48 CDT 2001



>I am attempting to get (from a popup) the ID of a class from an image >on 
>an opening page. I'm not having any luck. I'm looking for something >that 
>will work in IE 4+ and NS 4+....Any suggestions?

ID on IMG tag does not work in NN4 at all. Besides, what is 'clsItemPic' 
exactly? Should be the NAME of the image to work properly, so you already 
have the NAME/ID. Or is it a class? Then it won't work.

>//This does not work
>varImgSrc = eval('window.opener.document.images.clsItemPic.style.id');

Generally, to get the ID of an item you're almost correct:

varImgSrc = opener.document.images.clsItemPic.id;

You don't need the eval and id is a property of the object itself, not of 
the style. 'window.' is not necessary but won't hurt either.

But I don't think this is going to work on images in NN4.

ppk


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
-------------- next part --------------
An embedded message was scrubbed...
From: unknown sender
Subject: no subject
Date: no date
Size: 38
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20010801/86777a90/attachment.eml>


More information about the Javascript mailing list