Click to See Complete Forum and Search --> : js menu not working in frame


justmestl
12-10-2003, 03:38 PM
Ok....so, I'm having a problem with a js menu....inside a frame it's not showing up (has to be inside the frame b/c of how the site is set up...unfortunately), but if you open it up in a page on its own...it functions properly....is there something that can fix this?
Any help is appreciated.
Thanks!

soccer362001
12-10-2003, 04:24 PM
a link would be nice

justmestl
12-11-2003, 08:59 AM
Sorry, I'd send you a link but it's to an internal site for work...and no one outside can access it. :(

soccer362001
12-11-2003, 09:31 AM
can you post your code?

justmestl
12-11-2003, 02:17 PM
Yep, I actually just grabbed something off javascriptsource.com because i was being lazy (shame on me), perhaps I should go ahead and just write it myself from scratch.... Anywhoo here it goes. Thanks btw...for checking this out! :)



function InitMenu()
{
var bar = menuBar.children

for(var i=0;i < bar.length;i++)
{
var menu=eval(bar[i].menu)
menu.style.visibility = "hidden"
bar[i].onmouseover = new Function("ShowMenu("+bar[i].id+")")
var Items = menu.children
for(var j=0; j<Items.length; j++)
{
var menuItem = eval(Items[j].id)

if(menuItem.menu != null)
{
menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
//var tmp = eval(menuItem.id+"_Arrow")
// tmp.style.pixelLeft = menu.getBoundingClientRect().Right //- tmp.offsetWidth - 15
FindSubMenu(menuItem.menu)}

if(menuItem.cmd != null)
{
menuItem.onclick = new Function("Do("+menuItem.id+")") }

menuItem.onmouseover = new Function("highlight("+Items[j].id+")")

}

}
}
function FindSubMenu(subMenu)
{
var menu=eval(subMenu)
var Items = menu.children
for(var j=0; j<Items.length; j++)
{
menu.style.visibility = "hidden"
var menuItem = eval(Items[j].id)


if(menuItem.menu!= null)
{
menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
// var tmp = eval(menuItem.id+"_Arrow")
//tmp.style.pixelLeft = 35 //menuItem.getBoundingClientRect().right - tmp.offsetWidth - 15
FindSubMenu(menuItem.menu)
}

if(menuItem.cmd != null)
{
menuItem.onclick = new Function("Do("+menuItem.id+")") }

menuItem.onmouseover = new Function("highlight("+Items[j].id+")")

}
}
function ShowMenu(obj)
{
HideMenu(menuBar)
var menu = eval(obj.menu)
var bar = eval(obj.id)
bar.className="barOver"
menu.style.visibility = "visible"
menu.style.pixelTop = obj.getBoundingClientRect().top + obj.offsetHeight + Bdy.scrollTop
menu.style.pixelLeft = obj.getBoundingClientRect().left + Bdy.scrollLeft
}

function highlight(obj)
{
var PElement = eval(obj.parentElement.id)
if(PElement.hasChildNodes() == true)
{ var Elements = PElement.children
for(var i=0;i<Elements.length;i++)
{
TE = eval(Elements[i].id)
TE.className = "menuItem"
}
}
obj.className="ItemMouseOver"
window.defaultStatus = obj.title
ShowSubMenu(obj)
}

function Do(obj)
{
var cmd = eval(obj).cmd
// window.navigate(cmd)
self.location.href(cmd)

}

function HideMenu(obj)
{
if(obj.hasChildNodes()==true)
{
var child = obj.children

for(var j =0;j<child.length;j++)
{
if (child[j].className=="barOver")
{var bar = eval(child[j].id)
bar.className="Bar"}

if(child[j].menu != null)
{
var childMenu = eval(child[j].menu)
if(childMenu.hasChildNodes()==true)
HideMenu(childMenu)

childMenu.style.visibility = "hidden"
}
}

}
}
function ShowSubMenu(obj)
{
PMenu = eval(obj.parentElement.id)
HideMenu(PMenu)
if(obj.menu != null)
{
var menu = eval(obj.menu)
menu.style.visibility = "visible"
menu.style.pixelTop = obj.getBoundingClientRect().top + Bdy.scrollTop
menu.style.pixelLeft = obj.getBoundingClientRect().right + Bdy.scrollLeft
if(menu.getBoundingClientRect().right > window.screen.availWidth )
menu.style.pixelLeft = obj.getBoundingClientRect().left - menu.offsetWidth
}
}


I can't even get the menu to show up though...perhaps this is the problem...who knows....


<BODY OnLoad="InitMenu()" Onclick="HideMenu(menuBar)" ID="Bdy" bgColor=aliceblue>
<a name="top"></a>
<DIV Id="menuBar" class="menuBar" >
<DIV Id="Bar1" class="Bar" menu="menu1">aaa</DIV>
<DIV Id="Bar2" class="Bar" menu="menu2">bbb</DIV>
<DIV Id="Bar3" class="Bar" menu="menu3">ccc</DIV>
</DIV>
<!--MenuItem Definition -->
<div Id="menu1" class="menu" >
<div Id="menuItem1_1" class="menuItem" title="" cmd="inst.html">Instructions Home</div>

</div>
<div Id="menu2" class="menu">
<div Id="menuItem2_1" class="menuItem" cmd="abc.html">abc</div>
<div Id="menuItem2_2" class="menuItem" cmd="def.html">def</div>
<div Id="menuItem2_3" class="menuItem" cmd="ghi.html">ghi</div>
</div>
<div Id="menu3" class="menu">
<div Id="menuItem3_1" class="menuItem" cmd="contact.html">Contact Information</div>
</div><!-- End of Menu -->

<br /><br />
<!--Begin Header Table-->

I didn't include the whole page, this is probably more than enough though! Thanks again!

soccer362001
12-11-2003, 03:23 PM
how are you setting up your frames?

justmestl
12-11-2003, 03:52 PM
Since I can't just copy and paste the entirety of the page, b/c there's proprietary information included...and because I didn't actually set up the frames (it was set up back in '98)...yeah, I'd like to recommend them changing this, but so far, no go....anyway, from what I can tell, this is how it's set up:


<HTML>
<HEAD>
</HEAD>

<frameset cols="180,*" border=0 frameborder=0 framespacing=1>
<noframes>
</noframes>
<frame src="contents.html" name="contents" marginheight=5 marginwidth=10>
<frame src="main.html" name="main">
</frameset>
</html>

Here's some info that may or may not help. On main.html, there is a link, that goes to my page (the one WAY above, where the js isn't working). If you right click on that link (from main.html) and open in a new window the js menu works fine...which lead me to believe it wasn't a js error....but I thought perhpaps there was a compatibility dealio, since I don't usually work in frames (and especially NOT ones that I haven't set up)....

Hmm...I'm still just at a loss here...

Thanks for looking into this!!!

soccer362001
12-11-2003, 03:57 PM
Is the JS internal or external?

justmestl
12-12-2003, 09:00 AM
I've tried it both ways....but neither way works. :(

soccer362001
12-12-2003, 11:46 AM
Why dont you just have it open in a new window?

justmestl
12-12-2003, 11:50 AM
Yeah, I may do that....not sure how the team will feel about that, but it can't hurt to try it.

Thanks!
Have a great weekend!!!