On Error Resume Next

javascript Belgium
  • 18 years ago

    Hi All,


    Is there an On Error Resume Next statement like VB that I can use in JavaScript?


    rgds,
    Koen

  • 18 years ago

    There's an onError event e.g. when loading an image you might code
    <img src="image.jpg" onError="doSomething(this)">


    There's also an error method associated with a File object (server side stuff though).



    Have a look at:



    http://developer.netscape.com/docs/manuals/communicator/jsref/index.htm



    Otherwise you'll just have to code for all eventualities


    Hope this helps


    zing

  • 18 years ago

    Hi zingmatter,


    i've a function this is called when a mouse is over a table. when the mouse is over it the image must change BUT the images are held in an array. when you move your mouse to sone over the table and the images aren't loaded in the array yet then I get an error


    Code:

    function doOver(Index, img, nr)
    {    
         document.all.im[Index].className='iconmenuitemon';
         document.all.item[Index].className='menuitemon';
         if (img>=0)
         {
               //THIS IS WHERE I GET THE ERROR: IS NULL OR NOT AN OBJECT
               document.all.icon[img].src = imglist_on[nr].src;
         }
    }

  • 18 years ago

    I'm not sure, but you could be dealing with a browser issue. I think you might find the script will work in Netscape but not MSIE (or the other way round) as they handle the document object model differently.


    It's just when you code for hiding and showing style sheets elements you code:


    Code:

    if (document.layers) { //this is for Netscape
     visible = 'show';
     hidden = 'hide';
    } else if (document.all) { //this is for MSIE
     visible = 'visible';
     hidden = 'hidden';
    }


    function barTog(menu) {


      if (document.layers) {
        menu1 = document.layers[menu];
      } else if (document.all) {
        menu1 = document.all(menu).style
      }



      if (menu1.visibility == visible) {
        menu1.visibility = hidden;
      }
      else {
        menu1.visibility = visible;
      }
      if (lastMenu != menu) {
        closeMenus(lastMenu);
      }
      lastMenu = menu;


    }




    Just a thought anyway....


    zing

  • 18 years ago

    you could check the image's readystate property, or check if its null:


    if (document.all.icon[img]!=null)
      // do whatever


    etc

  • 18 years ago

    Thanx James,


    Thats what I need


    rgds,
    Koen

  • 18 years ago

    Thanx James,


    Thats what I need


    rgds,
    Koen

  • 18 years ago

    Thanx James,


    Thats what I need


    rgds,
    Koen

  • 18 years ago

    I've a big problem when I want to reply. I always get an error message and then I try again. this is the result 3 posts.




    sorry,
    Koen

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An expert is a man who has made all the mistakes that can be made in a very narrow field” - Niels Bohr