|
Prev: Need help with eval()
Next: double-byte character
From: dubing on 27 Sep 2005 10:05 Hi, Our webpage uses the following JavaScript code. function toggleSubmenu(divId, link) { var div = document.getElementById(divId); div.style.display = (div.style.display == 'block') ? "none" : "block"; if (link.className == "") link.className = "tempselected"; else link.className = ""; } Launching the page in IE pops up the error: A runtime error has occurred. Do you wish to debug? Line:188 Error: Object required The line reporting error is: div.style.display = (div.style.display == 'block') ? "none" : "block"; The version of IE I tested is 6.0.2900.2180.xpsp-sp2-gdr.050301-1519. The page does not return any errors in other browsers (e.g. Firefox, Netscape, etc.) How should I fix the error? Any help would be greatly appreciated. Bing
From: Mick White on 27 Sep 2005 10:24 dubing(a)gmail.com wrote: [snip] > > A runtime error has occurred. Do you wish to debug? Line:188 > Error: Object required > > The line reporting error is: > > div.style.display = (div.style.display == 'block') ? "none" : "block"; [snip] Try: div.style.display=div.style.display=="none"?"":"none"; Mick
From: Geoff Cox on 27 Sep 2005 13:44 On Tue, 27 Sep 2005 14:24:52 GMT, Mick White <mwhite13BOGUS(a)rochester.rr.com> wrote: >Try: > div.style.display=div.style.display=="none"?"":"none"; Mick, is above short for something else? if yes, could you please spell it out?! Thanks Geoff > >Mick
From: Mick White on 27 Sep 2005 14:35 Geoff Cox wrote: > On Tue, 27 Sep 2005 14:24:52 GMT, Mick White > <mwhite13BOGUS(a)rochester.rr.com> wrote: > > >>Try: >> div.style.display=div.style.display=="none"?"":"none"; > > > Mick, > > is above short for something else? if yes, could you please spell it > out?! > Google: "ternary operator", or "conditional operator". Mick
From: Geoff Cox on 27 Sep 2005 16:44 On Tue, 27 Sep 2005 18:35:08 GMT, Mick White <mwhite13BOGUS(a)rochester.rr.com> wrote: >Geoff Cox wrote: > >> On Tue, 27 Sep 2005 14:24:52 GMT, Mick White >> <mwhite13BOGUS(a)rochester.rr.com> wrote: >> >> >>>Try: >>> div.style.display=div.style.display=="none"?"":"none"; >> >> >> Mick, >> >> is above short for something else? if yes, could you please spell it >> out?! >> > Google: "ternary operator", or "conditional operator". Thanks MIck, Geoff >Mick
|
Pages: 1 Prev: Need help with eval() Next: double-byte character |