JavaScript error starts appearing from website in Internet Explorer

Posted on 2009-04-27
Last Modified: 2012-05-06
I have a web page which includes a javascript that performs an image rotator which had been working fine even in Internet Explorer when I got it all setup just a few months ago, but now when I open this page, it indicates the following error details:

Line 42
Char: 3
Error: 'null' is null or not an object
Code: 0

when I go to my source code, it seems to be pointing to the following line of code:


What I don't understand is why would it work before, and now it does not even with no changes, in Internet Explorer.  Intriguingly it does work when I open it in Firefox.
<script type="text/javascript">

var imgs1 = new Array("images/picture1.jpg",




var imgs2 = new Array("images/picture5.jpg",




var lnks1 = new Array("","","","");

var lnks2 = new Array("","","","");

var alt1 = new Array("","","","");

var alt2 = new Array("","","","");

var currentAd1 = 0;

var currentAd2 = 0;

var whichImg = 0;

var whichCtl = 2;

var imgCt1 = 4;

function cycle1() {

  if (currentAd1 == imgCt1) {

    currentAd1 = 0;


  if (currentAd2 == imgCt1) {

    currentAd2 = 0;


  if (whichImg == whichCtl) {

    whichImg = 0;


var banner1 = document.getElementById('adBanner1');

var banner2 = document.getElementById('adBanner2');

var link1 = document.getElementById('adLink1');

var link2 = document.getElementById('adLink2');







  if (whichImg == 0) {



  if (whichImg == 1) {






Open in new window

Question by:accucom
    LVL 18

    Expert Comment

    Can you provide some example page for that ? I paste this code to IE and it works ok :)

    Author Comment

    Here's the link in particular:
    LVL 18

    Accepted Solution

    I tried to install Microsoft Script Editor on this computer but I spent alot of time and I think that I found a problem without it :)

    just try instead of:

    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}


    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

    So this make sure that you refer to ID in document that is in fact created (2 sec can be not enough )

    Author Closing Comment

    Thanks wilq32, that worked, and still worked on Firefox so I'm happy now.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
    Hi, I am very much excited today since I'm going to share something very exciting Tool used for Analytical Reporting and that's nothing but MICROSTRATEGY. Actually there are lot of other tools available in the market for Reporting Such as Co…
    Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now