PDA

View Full Version : anylink css - set menu width in javascript?



faaf
02-08-2008, 08:23 PM
1) Script Title: AnyLink CSS Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/anylinkcss.htm

3) Describe problem: Currently the menu width must be set within the DIV or the CSS file as a style. Can the script be modified to set the menu width in the javascript like the AnyLink Drop Down Menu does? (AnyLink Drop Down Menu URL - http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm)

ddadmin
02-09-2008, 05:43 AM
Sure, just use the attached modified anylink.js file. With it, you can both specify a default menu width inside the .js file, and optionally for a particular drop down menu, a different width inline within the onMouseover code in the HTML:


<!--1st anchor link and menu -->

<a href="http://www.dynamicdrive.com" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'anylinkmenu1', '150px')">Anchor Link</a>

<div id="anylinkmenu1" class="anylinkcss">

<a href="http://www.dynamicdrive.com/">Dynamic Drive</a>
<a href="http://www.cssdrive.com">CSS Drive</a>
<a href="http://www.javascriptkit.com">JavaScript Kit</a>
<a href="http://www.codingforums.com">Coding Forums</a>
<a href="http://www.javascriptkit.com/jsref/">JavaScript Reference</a>

</div>

<!--2nd anchor link and menu -->

<a href="http://www.dynamicdrive.com" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'anylinkmenu2')">Anchor Link 2</a>

<div id="anylinkmenu2" class="anylinkcss" style="background-color: lightyellow">

<a href="http://www.cnn.com/">CNN</a>
<a href="http://www.msnbc.com">MSNBC</a>
<a href="http://www.google.com">Google</a>
<a href="http://news.bbc.co.uk">BBC News</a>

</div>

Here the 1st drop down is explicitly set to 150px, while the 2nd drop down, with no 4th parameter specified, will default to '200px', or what's set at the top of the .js file.