Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
DOM Script works in ff but causes error "'nodeList[...]' is null or not an object" in ie
Old 05-22-2006, 06:52 AM DOM Script works in ff but causes error "'nodeList[...]' is null or not an object" in ie
Junior Talker

Posts: 2
Trades: 0
Hi. I have created a javascript testimonial rotator in the style of http://en.helldesign.pl/ at http://www.ourprojects.biz/borderline/site/ and it works fine in Firefox but for some reason in Internet Explorer the error "'nodeList[...]' is null or not an object" appears when the script is run.

My page contains eight testimonials in an unordered list. Every 10 seconds the script is called. My CSS sets them all to display none, except for the one with class="conspic".
HTML Code:
        <script type="text/javascript">
            setInterval("timing()",10000);
        </script>
The script then goes through the list, fades out the current testimonial, makes the next one down active by changing the class, and then fades it in using a script.aculo.us effect. There are also seven other list items on the page before my testimonials so when it gets to the last testimonial I start again from the eighth list item.



Code:
// JavaScript Document
var flag = 0;
var cnt = -1;
var nodeList = document.getElementsByTagName("li");

function timing()  {
    flag = 0;
    cnt = -1;
    while (flag==0){
        cnt++;
        rotation(cnt);
    }
}
    
function rotation(i) {
    if (nodeList[i].getAttribute('class')=="conspic"){
        new Effect.Fade('testimonials',{ 
            afterFinish : function(effect){
                nodeList[i].setAttribute('class','');
                if (i>13)
                nodeList[7].setAttribute('class','conspic');
                else
                nodeList[i+1].setAttribute('class','conspic');
                new Effect.Appear('testimonials');
            }                         
        });
        flag = 1;
    }
}
Anyone got any ideas why it don't work in IE or maybe even a more efficient way to do this?
mzzarh is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-22-2006, 07:01 AM Re: DOM Script works in ff but causes error "'nodeList[...]' is null or not an object" in ie
Ultra Talker

Posts: 256
Location: Auckland, New Zealand
Trades: 0
Elements in the DOM are UPPERCASE. When you use this, it should be this:

HTML Code:
var nodeList = document.getElementsByTagName('LI');
Also because class is a reserved keyword in javascript, you can't get the attribute like that, you must do:

HTML Code:
if(nodeList[i].className == 'conspic') { ...
As well as using className in all the cases that use 'class'.

Cheers,

MC
__________________
#------------------------------signature---------------------------------------------------------------------------------#
Quote:
I am well recognised for what I don't do than what I do. Chores are just one of those things.

Last edited by mastercomputers; 06-01-2006 at 01:20 PM..
mastercomputers is offline
Reply With Quote
View Public Profile Visit mastercomputers's homepage!
 
Old 05-22-2006, 07:24 AM Re: DOM Script works in ff but causes error "'nodeList[...]' is null or not an object
Junior Talker

Posts: 2
Trades: 0
Thanks so much for your quick response, it works absolutely fine now!
mzzarh is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to DOM Script works in ff but causes error "'nodeList[...]' is null or not an object" in ie
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.48142 seconds with 12 queries