We help IT Professionals succeed at work.

MyRawClassName = eSelected.getAttribute('className');   firefox not working.

aplimedia
aplimedia asked
on
403 Views
Last Modified: 2008-04-24
Please take a look at the below script lines...

MyRawClassName = eSelected.getAttribute('className');
window.alert(MyRawClassName);
return;

//IE returns the correct class name...
//Firfox returns 'null'

//same with the following:

GetThisImage = document.getElementById(theImageId);
TheImageWidth = document.getElementById(theImageId).width

// does it correctly Firefox.... not so. ;-(

What am I doing wrong?


Aplimedia
Comment
Watch Question

IT Manager
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
I just noticed that the last half may be a second part.  It wasn't really clear though.  Do you have a question about that too?  Which part didn't work if there was a problem?  Was it just in Firefox and IE worked?

bol
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
If you do have a question about the second part (the image) then let me see the image tag, the part of the page that calls the function or script you posted, and any additional script with those 2 lines.  The problem may be how it is called.  As always when using getElementById() make sure the id is unique on the page and assigned in the element.  A name attribute will work in IE as an ID but Firefox isn't so lenient.

bol

Author

Commented:
soryy I have been away... getting to these now.


Aplimedia

Author

Commented:
Ok,

.................................................>>
MyRawClassName = (eSelected.getAttribute('className'))? eSelected.getAttribute('className') : eSelected.className;
window.alert(MyRawClassName);
return;
.................................................>>

That works... !!!

I start out my using getElementsByName() becuase the name is all I have to start off with. I retrieve the ID and use that for everything else.

Aplimedia

Author

Commented:
Second bit also works well now.

Many thanks

Aplimedia
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
Your welcome!  I'm glad I could help.  Thanks for the grade, the points and the fun question.

bol
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.