Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE gives me a JavaScript error message of "'style' is not an object"

Status
Not open for further replies.

javascript1

Programmer
Nov 20, 2000
2
US
Hi,

I am trying to generate a popup menu in a table using Javascript. Here is my code. I got the menu.js file from Gary Smith's website. This works fine in Netscape. But ib IE , I get an error message which says 'style' is not an object. I would appreciate if someone helps me to solve this problem.
<html>

<head>
<title>Popup Menu</title>



</head>

<SCRIPT LANGUAGE=&quot;JavaScript1.2&quot; SRC=&quot;menu.js&quot;> </SCRIPT>

<body>
<TABLE>
<TR>
<TD VALIGN=TOP NOWRAP>
<script language = &quot;JavaScript1.2&quot;>
if (document.all)
{
window.myMenu = new Menu();
myMenu.addMenuItem(&quot;my menu item A&quot;);
myMenu.addMenuItem(&quot;my menu item B&quot;);
myMenu.addMenuItem(&quot;my menu item C&quot;);
myMenu.addMenuItem(&quot;my menu item D&quot;);
myMenu.writeMenus();
}
else
if (document.layers)
{
window.myMenu = new Menu();
myMenu.addMenuItem(&quot;my menu item A&quot;);
myMenu.addMenuItem(&quot;my menu item B&quot;);
myMenu.addMenuItem(&quot;my menu item C&quot;);
myMenu.addMenuItem(&quot;my menu item D&quot;);
myMenu.writeMenus();
}

</script>


<LI><A HREF=&quot;javascript:window.showMenu(window.myMenu);&quot;
onClick=&quot;window.showMenu(window.myMenu);&quot;>myMenu</A>


</TD>
</TR>

</TABLE>
</body>
</html>






 
the error doesn't come from the code you copied here ...
 
Hi iza,

The error comes from the code in menu.js file. It is here
l.style.visibility = &quot;inherit&quot;;
I get the error in the following function. Can you help me out with this problem.

function showMenu(menu, x, y, child) {
if (!window.wroteMenu) return;
if (document.layers) {
if (menu) {
var l = menu.menuLayer || menu;
if (typeof(menu) == &quot;string&quot;) {
for (var n=0; n < menuContainers.length; n++) {
l = menuContainers[n].menus[menu];
for (var i=0; i<menuContainers[n].menus.length; i++) {
if (menu == menuContainers[n].menus.label) l = menuContainers[n].menus.menuLayer;
if (l) break;
}
}
if (!l) return;
}
l.Menu.container.document.bgColor = null;
l.left = 1;
l.top = 1;
hideActiveMenus(l);
if (this.visibility) l = this;
window.ActiveMenu = l;
window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);
setTimeout('if(window.ActiveMenu)window.ActiveMenu.Menu.setMouseTracker();', 300);
} else {
var l = child;
}
if (!l) return;
for (var i=0; i<l.layers.length; i++) {
if (!l.layers.isHilite)
l.layers.visibility = &quot;inherit&quot;;
if (l.layers.document.layers.length > 0)
showMenu(null, &quot;relative&quot;, &quot;relative&quot;, l.layers);
}
if (l.parentLayer) {
if (x != &quot;relative&quot;)
l.parentLayer.left = x || window.pageX || 0;
if (l.parentLayer.left + l.clip.width > window.innerWidth)
l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
if (y != &quot;relative&quot;)
l.parentLayer.top = y || window.pageY || 0;
if (l.parentLayer.isContainer) {
l.Menu.xOffset = window.pageXOffset;
l.Menu.yOffset = window.pageYOffset;
l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
if (l.parentLayer.menuContainerBgColor) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
}
}
l.visibility = &quot;inherit&quot;;
if (l.Menu) l.Menu.container.visibility = &quot;inherit&quot;;
} else if (document.all) {
var l = menu.menuLayer || menu;
hideActiveMenus(l);
if (typeof(menu) == &quot;string&quot;) {
l = document.all[menu];
for (var n=0; n < menuContainers.length; n++) {
l = menuContainers[n].menus[menu];
for (var i=0; i<menuContainers[n].menus.length; i++) {
if (menu == menuContainers[n].menus.label) l = menuContainers[n].menus.menuLayer;
if (l) break;
}
}
}
window.ActiveMenu = l;
l.style.visibility = &quot;inherit&quot;;
if (x != &quot;relative&quot;)
l.style.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
if (y != &quot;relative&quot;)
l.style.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
l.Menu.xOffset = document.body.scrollLeft;
l.Menu.yOffset = document.body.scrollTop;
}
if (menu) {
window.activeMenus[window.activeMenus.length] = l;
}
}

Thanks.
 
i dont have much time to check what's actually in I but it's either an object that doesn't have the style property or you're missing something in building I

if between window.ActiveMenu=I and I.Style.visi.... you add
alert(typeof(I)) what does it show ?? is that what it's supposed to be ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top