...

View Full Version : function target path



neonwhiskey
02-24-2003, 08:31 PM
hi, here's a JS file, which gives an error that 'menu1 is not defined'. I'm trying to make a drop down, which I'll be able to re-use anywhere in my site, but having trouble setting visibility, and suppose I'll have trouble passing the link names to the JS file. Help? ; )
Jenny

document.write("<style>table{font size:10pt}tr background:#209090}a{color:#000000; text-decoration:none; font:bold}a:hover{color:#FFFFFF}td.menu{background:408060; font-size:10pt; position:absolute; visibility:hidden; z-index=1000}</style>")

function setVisibility (menuName)
{
menu1.onmouseover="document.subMenu1.style.visibility='visible'";
menu1.onmouseout="document.subMenu1.style.visibility='hidden'";
}

document.write('<table cellpadding=0 cellspacing=0 border=0><tr>')
document.write('<td id="menu1"')

document.write('<table cellpadding=3 cellspacing=1 border="0" width=100%><tr>')
document.write('<td nowrap><a href="../link1.html">Menu Item 1</a></td>')
document.write('</tr></table>')

document.write('<table cellpadding=3 cellspacing=1 border=0 class="menu" id="subMenu1" width=100%>')
document.write('<tr><td class="menu"><a href="../html">HTML</a></td></tr>')
document.write('<tr><td class="menu"><a href="../xhtml">XHTML</a></td></tr>')
document.write('<tr><td class="menu"><a href="../css">CSS</a></td></tr>')
document.write('<tr><td class="menu"><a href="../xml">XML</a></td></tr>')
document.write('<tr><td class="menu"><a href="../xsl">XSL</a></td></tr>')
document.write('</table>')

document.write('</td></tr></table>')

window.onload=setVisibility;

Roy Sinclair
02-24-2003, 09:36 PM
In this function:



function setVisibility (menuName)
{
function setVisibility (menuName)
{
menu1.onmouseover="document.subMenu1.style.visibility='visible'";
menu1.onmouseout="document.subMenu1.style.visibility='hidden'";
}
="document.subMenu1.style.visibility='visible'";
menu1.onmouseout="document.subMenu1.style.visibility='hidden'";
}


Why pass "menuName" and then not use it within the code?

Where you have menu1.onmouseover you should have document.getElementById('menu1').onmouseover and then you're just setting the event to a string which is also wrong (it may look like code but it's just a string", you need to set the event to a function.

neonwhiskey
02-24-2003, 11:37 PM
I was sending the variable because there might be more than one drop-down, and because the actual links will have to be passed through also. I did not understand your answer... 'you need to set the event to a function.' I am trying to write a function...
pls, if you could explain? thx!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum