473,830 Members | 2,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getAttribute('s tyle') not working in IE

CES


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.getEle mentById('test' ).innerHTML = document.getEle mentById('id_Co mpanyName').get Attribute('styl e');
<div class="dR4C2">
<p id="id_CompanyN ame" style="font-size:<%=aspName FontSize%>px;">
<%=aspCompanyNa me%>
</p>
</div>

It seems to be a problem with the getAttribute('s tyle') portion of the code because if I change the request to getAttribute('i d') 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
Nov 24 '05 #1
2 12316
VK
<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.getEle mentById('id_Co mpanyName').get Attribute('styl e');
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="#FFFFF F" onload="test()" >
<div class="dR4C2">
<p id="id_CompanyN ame" style="font-size:10px;">&nb sp;</p>
</div>
</body>
</html>

:-)

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

Nov 24 '05 #2
CES
VK wrote:
<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.getEle mentById('id_Co mpanyName').get Attribute('styl e');
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="#FFFFF F" onload="test()" >
<div class="dR4C2">
<p id="id_CompanyN ame" style="font-size:10px;">&nb sp;</p>
</div>
</body>
</html>

:-)

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


VK,

Thanks for the help... - CES
Nov 24 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5466
by: CES | last post by:
All, I'm at a loss, the code below works in IE but not in Netscape and I'm unskilled enough not to know why. Essentially this code looks thru all of the form fields and if the input box has a attribute of disabled="true", attribute would only be present if the field was disabled, then the label field's class is changed to a grayed out color. --- The first problem seems to be with the v==true statement, I've tried
12
3099
by: relaxedrob | last post by:
Hi All! I have a page with with the following style information: <link rel="stylesheet" type="text/css" href="/eEmployment/eTech.css" /> <style type="text/css"> DIV.Application { BACKGROUND-IMAGE:url(/someImage.jpg); }
3
21929
by: hutch | last post by:
Hi, I'm making use of this VERY useful function for a so called 'standards compliant' replacement for target="_blank": function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors;
5
1385
by: verrice | last post by:
Hello, I'm writing a web application where I want to load bits of data at runtime from the client end (via AJAX). The loading of the data part works great, but for some reason anytime I try to impart a style setting (via either putting it inline, a CSS, or through javascript) the DIV completely ignores my setting. The setting most importantly I'm trying to apply is display: none, but none of them work. If I pre-create everything...
7
1929
by: T J Rogers | last post by:
Hi folks, Below is a script that I use on a site to detect the size of the browser window then automatically load an alternative stile sheet when appropriate. Its a bit clumsy, and I don't like using js but the the brief demanded a solution. Now the only difference between the two style sheets is one line:
2
6529
by: emma.sax | last post by:
Hi I have the following code which is working in Firefox: function showOptions() { if(!document.getElementById) return false; if(!document.getElementsByTagName) return false; var lnks = document.getElementsByTagName("a"); for(var i=0; i<lnks.length; i++) { alert(lnks.getAttribute("class"));
0
1627
by: sandy | last post by:
I have a AxWebBrowser class. I wish to locate a specific element in its HTMLDocument which has a specific 'style'. I use the following code to access the element with the specific style:- IHTMLDocument2 doc = (HTMLDocumentClass)Browser1.Document; if( doc.body != null && doc.body.all != null) { foreach(IHTMLElement el in (IHTMLElementCollection)doc.body.all)
6
6189
by: vivekian | last post by:
Hi , In one of the javascript functions , i need to get the ids of the elements. This function works in Internet Explorer : var TabNames = ParentTab.childNodes ; for ( i = 0 ; i < TabNames.length ; i++ ) { var TabID = TabNames.getAttribute('id') ;
4
5058
by: ICPooreMan | last post by:
I've got some code which works in firefox that's giving me fits in IE7 (maybe other versions too I haven't tested it). What I want to do is get the oncontextmenu attribute of something, change the value then put it back as the oncontextmenu attribute. Here's an example page if you want to try it out... <html> <head> <titletesting </title> <script><!--
0
9793
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10526
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7747
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5617
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3960
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.