473,395 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

script not working in IE 6

Hi

I'm very new to web scripting. Can someone tell me why this snippet
will work as expected in Mozilla 1.4 but not IE 6.0? I thought this
script should work in any browser compatible with W3C DOM. Any help is
greatly appreciated.

<script>

function turnRed(){
var elem=document.getElementsByTagName("DIV");
elem.item(1).setAttribute("style","color:red");
}

</script>

<DIV ID="div1">Div #1</DIV>
<DIV ID="div2">Div #2</DIV>
<DIV ID="div3">Div #3</DIV>
<INPUT TYPE="button" VALUE="Turn #2 Red" onclick="turnRed()">

Jul 20 '05 #1
3 3411

"J Weaver" <sc********@yah00.com> schreef in bericht
news:pFdqb.311721$9l5.57447@pd7tw2no...

I'm very new to web scripting. Can someone tell me why this snippet
will work as expected in Mozilla 1.4 but not IE 6.0? I thought this
script should work in any browser compatible with W3C DOM. Any help is
greatly appreciated.


IE is not fully compliant. The following will work in both IE and Mozilla:

function turnRed(){
var elem=document.getElementsByTagName("DIV");
elem.item(0).style.color = "red";
}
JW

Jul 20 '05 #2
J Weaver wrote:
I'm very new to web scripting. Can someone tell me why this snippet
will work as expected in Mozilla 1.4 but not IE 6.0? I thought this
script should work in any browser compatible with W3C DOM. elem.item(1).setAttribute("style","color:red");


MSIE doesn't support setAttribute.

I won't swear to it, but I think setAttribute is DOM2, and MSIE only
supports DOM1.

--
David Dorward http://dorward.me.uk/
Jul 20 '05 #3
On Wed, 5 Nov 2003, David Dorward wrote:
MSIE doesn't support setAttribute.


MSIE "supports" it. But it's just so bug ridden it might as well not have.
The difference between no support, and crappy support, is that the latter
is much more dangerous.

Regards,
Svend
Jul 20 '05 #4

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

Similar topics

9
by: Flynn | last post by:
My understanding of javascript is very limited. Could some one help me out. I found this code for an image gallery viewer. It works fine on my site, but I'd like to modify it so that the mainpic...
2
by: Nasir Wasim | last post by:
How can Access DIV Properties in Script while using Netscape 7.2. I want to use the div id with it's Visibility and left propertyin script but it's not working :-( Main File : ----------- ...
0
by: ZMan | last post by:
Scenario: This is about debugging server side scripts that make calls to middle-tier business DLLs. The server side scripts are legacy ASP 3.0 pages, and the DLLs are managed DLLs...
1
by: Steve Richter | last post by:
have just installed the Microsoft script debugger for windows 2000: http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&displaylang=en ( notice the "this...
1
by: Q1tum | last post by:
Hi all, I have a problem with my script, I'm using javascript DOM to update my page. The getPortals() function updates a select list whichs shows portals. The doUpdate() function updates a...
19
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
2
by: Tereska | last post by:
I want to delete script added before. I'm adding script dynamically and i'm removing later. Why it is still working? I have something like this: <html> <head> <title>JS Script...
9
by: whitgurley | last post by:
I've searched the web as well as I can for a solution to this problem but have found nothing and just don't know enough about JavaScript to figure out what's going. What I'm trying to do is convert...
9
by: Jerim79 | last post by:
Here it is: <?php if($_SERVER=='POST'){ $Number=$_POST; $Email=$_POST; $Number2=0; $error=0;
3
by: malaysiauser | last post by:
Dear all, Last year I install a download control script in Linux server. its working. This year i'd changed my hosting server to other company. i'd tried install the script. It was installed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.