Connecting Tech Pros Worldwide Forums | Help | Site Map

getAttribute('style') not working in IE

CES
Guest
 
Posts: n/a
#1: Nov 24 '05


All,

I'm 2 for 2 on stupid questions this works in FireFox but not in IE it's not returning the value of the style element and I'm getting [object] error??

document.getElementById('test').innerHTML = document.getElementById('id_CompanyName').getAttri bute('style');


<div class="dR4C2">
<p id="id_CompanyName" style="font-size:<%=aspNameFontSize%>px;">
<%=aspCompanyName%>
</p>
</div>

It seems to be a problem with the getAttribute('style') portion of the code because if I change the request to getAttribute('id') it executes properly. If someone could look at this an give me some hint as to why it isn't working in IE I be great full Thanks in advance. - CES

VK
Guest
 
Posts: n/a
#2: Nov 24 '05

re: getAttribute('style') not working in IE


<html>
<head>
<title>tmp</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script type="text/javascript">
function test() {
var s =
document.getElementById('id_CompanyName').getAttri bute('style');
if (typeof s == 'string') {
alert(s);
}
else if (typeof s == 'object') {
alert(s.cssText);
}
else {
var mes = 'What you call \"my browser\" is not a browser.\n';
mes+= 'Do you want a normal browser?';
if (confirm(mes)) {
window.location.href = 'http://www.mozilla.org';
}
}
}
</script>
</head>

<body bgcolor="#FFFFFF" onload="test()">
<div class="dR4C2">
<p id="id_CompanyName" style="font-size:10px;">&nbsp;</p>
</div>
</body>
</html>

:-)

Whatch the case! For further development convenience Mozilla brings
everything to the lower case and IE to the upper case.

CES
Guest
 
Posts: n/a
#3: Nov 24 '05

re: getAttribute('style') not working in IE


VK wrote:[color=blue]
> <html>
> <head>
> <title>tmp</title>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1">
> <script type="text/javascript">
> function test() {
> var s =
> document.getElementById('id_CompanyName').getAttri bute('style');
> if (typeof s == 'string') {
> alert(s);
> }
> else if (typeof s == 'object') {
> alert(s.cssText);
> }
> else {
> var mes = 'What you call \"my browser\" is not a browser.\n';
> mes+= 'Do you want a normal browser?';
> if (confirm(mes)) {
> window.location.href = 'http://www.mozilla.org';
> }
> }
> }
> </script>
> </head>
>
> <body bgcolor="#FFFFFF" onload="test()">
> <div class="dR4C2">
> <p id="id_CompanyName" style="font-size:10px;">&nbsp;</p>
> </div>
> </body>
> </html>
>
> :-)
>
> Whatch the case! For further development convenience Mozilla brings
> everything to the lower case and IE to the upper case.
>[/color]

VK,

Thanks for the help... - CES
Closed Thread