470,613 Members | 2,205 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

runtime error: object required?

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

Sep 27 '05 #1
4 15486
du****@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"?"":"no ne";

Mick
Sep 27 '05 #2
On Tue, 27 Sep 2005 14:24:52 GMT, Mick White
<mw***********@rochester.rr.com> wrote:
Try:
div.style.display=div.style.display=="none"?"":"no ne";
Mick,

is above short for something else? if yes, could you please spell it
out?!

Thanks

Geoff



Mick


Sep 27 '05 #3
Geoff Cox wrote:
On Tue, 27 Sep 2005 14:24:52 GMT, Mick White
<mw***********@rochester.rr.com> wrote:

Try:
div.style.display=div.style.display=="none"?"":"no ne";

Mick,

is above short for something else? if yes, could you please spell it
out?!

Google: "ternary operator", or "conditional operator".
Mick
Sep 27 '05 #4
On Tue, 27 Sep 2005 18:35:08 GMT, Mick White
<mw***********@rochester.rr.com> wrote:
Geoff Cox wrote:
On Tue, 27 Sep 2005 14:24:52 GMT, Mick White
<mw***********@rochester.rr.com> wrote:

Try:
div.style.display=div.style.display=="none"?"":"no ne";

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


Sep 27 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Geoff Cox | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.