[thelist] simple Javascript help

Drew Shiel ashiel at sportsinteraction.com
Fri Nov 1 11:28:01 CST 2002


At 17:35 01/11/2002 +0000, Chris Marsh wrote:

   Hi Chris;

   Feeling remarkably dumb right now, but what function should I call on
the OnChange for all this to take effect?

   It looks great, even if I understand only about a quarter of it. :)

   Drew.


> > > Now, this works fine in IE, but Netscape complains about
> > document.all
> > > not existing.
> > >
> > > Can this be done in Netscape?
> >
> > The document.all object does not exist in Netscape, like the
> > error indicated.  Instead, use the getElementById function.
> > Make sure that the elements have the id attribute set.
>
>Or even better, do something a little like the followng:
>
>function ElementObject(s) {
>   if(document.getElementById) {
>     var e = document.getElementById(s);
>     var o = 2;
>   }
>   else if(document.all) {
>     var e = document.all[s];
>     var o = 1;
>   }
>   else if(document.layers) {
>     var e = document.layers[s];
>     var o = 0;
>   }
>   this.ElementName = s;
>   this.ObjectSupport = o;
>   this.ElementO = e;
>}
>
>function StyleObject(s) {
>   var eo = new ElementObject(s);
>   var e = eo.ElementO;
>   var o = eo.ObjectSupport;
>   switch(o) {
>     case 2:
>       var t = e.style;
>       break;
>     case 1:
>       var t = e.style;
>       break;
>     case 0:
>       var t = e;
>       break;
>   }
>   this.StyleO = t;
>}
>
>Then...
>
>var s = new StyleObject('id');
>var so = s.StyleO;
>so.visibility = 'visible';
>
>HTH
>
>Regards
>
>Chris Marsh
>
>
>--
>For unsubscribe and other options, including
>the Tip Harvester and archive of thelist go to:
>http://lists.evolt.org Workers of the Web, evolt !

Drew Shiel                               webmaster at swiftpay.com
                                                     +353-1-2365705
------------------------------------------------------------------
Swiftpay -- The best way to pay online -- http://www.swiftpay.com




More information about the thelist mailing list