hi you lot.. i have a problem with a drop down menu ive made. and i need to get it working as soon as i can so any help would really be appreciated
the menu is here, it seems to work but there are a couple of problems..
http://bb.1asphost.com/antonyx6/menu/dropdown.html
Problem 1: Im using the dreamweaver rollover image code for the rollover buttons.. in my body tag it says to load all the images being used like so..
The problem is that when the page loads, and you mouse over one of the menu items.. the 2nd rollover image hasnt already loaded and it takes a few moments for it to appear..
Question 1: is there anyway to ensure that all the rollover images load immediately so this delay affect does not occur.
Problem 2: As you go from one menu column to another, i realised i could alter the delay time using this..
this makes the transition from one menu to the next pretty instant which is what i want.. but there is a problem.. sometimes when the mouse is over the top item for too long or too short a time.. you move down towards the menu items for that selection and they disappear...
Question 2: Can i ensure that the transition between the menus is instant like it is currently but also make sure that the menu items below the chosen menu heading will always be active and selectable always if the mouse is hovering over the menu header..
i am fairly profficient with html and css but my javascript is not wonderful which i why im having trouble customising this system..
here is the tutorial i used..
http://www.dynamicdrive.com/dynamicindex1/dropdowncontrol.htm
if these 2 issues could be resolved then i think the menu will be ready and i will be very grateful..
below is the javascript code for the actual page with the divs and the js functions.. thanks again.
js menu functions
and my page at the moment
the menu is here, it seems to work but there are a couple of problems..
http://bb.1asphost.com/antonyx6/menu/dropdown.html
Problem 1: Im using the dreamweaver rollover image code for the rollover buttons.. in my body tag it says to load all the images being used like so..
Code:
<body onLoad="MM_preloadImages('fleet.jpg','fleet2.jpg','exec.jpg','exec2.jpg..etc')">
The problem is that when the page loads, and you mouse over one of the menu items.. the 2nd rollover image hasnt already loaded and it takes a few moments for it to appear..
Question 1: is there anyway to ensure that all the rollover images load immediately so this delay affect does not occur.
Problem 2: As you go from one menu column to another, i realised i could alter the delay time using this..
Code:
function at_hide()
{
c = document.getElementById(this["at_child"]);
c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", [b]0.8[/b]);
}
this makes the transition from one menu to the next pretty instant which is what i want.. but there is a problem.. sometimes when the mouse is over the top item for too long or too short a time.. you move down towards the menu items for that selection and they disappear...
Question 2: Can i ensure that the transition between the menus is instant like it is currently but also make sure that the menu items below the chosen menu heading will always be active and selectable always if the mouse is hovering over the menu header..
i am fairly profficient with html and css but my javascript is not wonderful which i why im having trouble customising this system..
here is the tutorial i used..
http://www.dynamicdrive.com/dynamicindex1/dropdowncontrol.htm
if these 2 issues could be resolved then i think the menu will be ready and i will be very grateful..
below is the javascript code for the actual page with the divs and the js functions.. thanks again.
js menu functions
Code:
// <script>
// Copyright (C) 2005 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: [URL unfurl="true"]http://www.php-development.ru/[/URL]
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Distribute this code, any part or any modified version of it.
// Instead, you can link to the homepage of this code:
// [URL unfurl="true"]http://www.php-development.ru/javascripts/smart-forms.php.[/URL]
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as a part of another product provided that
// its main use is not creating javascript menus.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind, either
// expressed or implied, including, but not limited to, the implied warranties
// of merchantability and fitness for a particular purpose. You expressly
// acknowledge and agree that use of this code is at your own risk.
// If you find my script useful, you can support my site in the following ways:
// 1. Vote for the script at HotScripts.com (you can do it on my site)
// 2. Link to the homepage of this script or to the homepage of my site:
// [URL unfurl="true"]http://www.php-development.ru/javascripts/smart-forms.php[/URL]
// [URL unfurl="true"]http://www.php-development.ru/[/URL]
// You will get 50% commission on all orders made by your referrals.
// More information can be found here:
// [URL unfurl="true"]http://www.php-development.ru/affiliates.php[/URL]
// ----- Popup Control ---------------------------------------------------------
function at_display(x)
{
win = window.open();
for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}
// ----- Show Aux -----
function at_show_aux(parent, child)
{
var p = document.getElementById(parent);
var c = document.getElementById(child);
var top = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;
for (; p; p = p.offsetParent)
{
top += p.offsetTop;
left += p.offsetLeft;
}
c.style.position = "absolute";
c.style.top = top +'px';
c.style.left = left+'px';
c.style.visibility = "visible";
}
// ----- Show -----
function at_show()
{
p = document.getElementById(this["at_parent"]);
c = document.getElementById(this["at_child" ]);
at_show_aux(p.id, c.id);
clearTimeout(c["at_timeout"]);
}
// ----- Hide -----
function at_hide()
{
c = document.getElementById(this["at_child"]);
c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 0.8);
}
// ----- Click -----
function at_click()
{
p = document.getElementById(this["at_parent"]);
c = document.getElementById(this["at_child" ]);
if (c.style.visibility != "visible") at_show_aux(p.id, c.id);
else c.style.visibility = "hidden";
return false;
}
// ----- Attach -----
// PARAMETERS:
// parent - id of visible html element
// child - id of invisible html element that will be dropdowned
// showtype - "click" = you should click the parent to show/hide the child
// "hover" = you should place the mouse over the parent to show
// the child
// position - "x" = the child is displayed to the right of the parent
// "y" = the child is displayed below the parent
// cursor - Omit to use default cursor or check any CSS manual for possible
// values of this field
function at_attach(parent, child, showtype, position, cursor)
{
p = document.getElementById(parent);
c = document.getElementById(child);
p["at_parent"] = p.id;
c["at_parent"] = p.id;
p["at_child"] = c.id;
c["at_child"] = c.id;
p["at_position"] = position;
c["at_position"] = position;
c.style.position = "absolute";
c.style.visibility = "hidden";
if (cursor != undefined) p.style.cursor = cursor;
switch (showtype)
{
case "click":
p.onclick = at_click;
p.onmouseout = at_hide;
c.onmouseover = at_show;
c.onmouseout = at_hide;
break;
case "hover":
p.onmouseover = at_show;
p.onmouseout = at_hide;
c.onmouseover = at_show;
c.onmouseout = at_hide;
break;
}
}
and my page at the moment
Code:
<html>
<head>
<title>Dropdown Sample</title>
<script type="text/javascript" src="dropdown.js">
</script>
<script type="text/javascript" src="image.js">
</script>
</head>
<body onLoad="MM_preloadImages('fleet.jpg','fleet2.jpg','exec.jpg','exec2.jpg','acc.jpg','acc2.jpg',
'quote.jpg','quote2.jpg','air.jpg','air2.jpg','sea.jpg',sea2.jpg','day.jpg','day2.jpg','enq.jpg',
'enq2.jpg','book.jpg','book2.jpg','faq.jpg','faq2.jpg','site.jpg','site2.jpg','tc.jpg','tc2.jpg',
'gen.jpg','gen2.jpg','hotels.jpg','hotels2.jpg','events.jpg','events2.jpg')">
<h3>Dropdown Sample</h3>
<!-- Dropdown Menu -->
<div id="menu_parent"
style="width: 47px; border:0px; padding: 0px 0px; float:left;">
<img src="home.jpg"/>
</div>
<div id="menu2_parent"
style="width: 63px; border:0px; padding: 0px 0px; float:left;">
<img src="services.jpg"/>
</div>
<div id="menu2_child"
style="position: absolute; visibility: hidden; background: #ffffff;">
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','fleet2.jpg',1)"><img
src="fleet.jpg" name="Image1" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','exec2.jpg',1)"><img
src="exec.jpg" name="Image2" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','acc2.jpg',1)"><img
src="acc.jpg" name="Image3" width="144" height="26" border="0"></a><br>
</div>
<script type="text/javascript">
at_attach("menu2_parent", "menu2_child", "hover", "y", "pointer");
</script>
<div id="menu3_parent"
style="width: 47px; border:0px; padding: 0px 0px; float:left;">
<img src="rates.jpg"/>
</div>
<div id="menu3_child"
style="position: absolute; visibility: hidden; background: #ffffff;">
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','quote2.jpg',1)"><img
src="quote.jpg" name="Image4" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','air2.jpg',1)"><img
src="air.jpg" name="Image5" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','sea2.jpg',1)"><img
src="sea.jpg" name="Image6" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','day2.jpg',1)"><img
src="day.jpg" name="Image7" width="144" height="26" border="0"></a><br>
</div>
<script type="text/javascript">
at_attach("menu3_parent", "menu3_child", "hover", "y", "pointer");
</script>
<div id="menu4_parent"
style="width: 137px; border:0px; padding: 0px 0px; float:left;">
<img src="enqbook.jpg"/>
</div>
<div id="menu4_child"
style="position: absolute; visibility: hidden; background: #ffffff;">
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','enq2.jpg',1)"><img
src="enq.jpg" name="Image8" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','book2.jpg',1)"><img
src="book.jpg" name="Image9" width="144" height="26" border="0"></a><br>
</div>
<script type="text/javascript">
at_attach("menu4_parent", "menu4_child", "hover", "y", "pointer");
</script>
<div id="menu5_parent"
style="width: 35px; border:0px; padding: 0px 0px; float:left;">
<img src="info.jpg"/>
</div>
<div id="menu5_child"
style="position: absolute; visibility: hidden; background: #ffffff;">
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','faq2.jpg',1)"><img
src="faq.jpg" name="Image10" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','tc2.jpg',1)"><img
src="tc.jpg" name="Image11" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','site2.jpg',1)"><img
src="site.jpg" name="Image12" width="144" height="26" border="0"></a><br>
</div>
<script type="text/javascript">
at_attach("menu5_parent", "menu5_child", "hover", "y", "pointer");
</script>
<div id="menu6_parent"
style="width: 44px; border:0px; padding: 0px 0px; float:left;">
<img src="links.jpg"/>
</div>
<div id="menu6_child"
style="position: absolute; visibility: hidden; background: #ffffff;">
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image13','','gen2.jpg',1)"><img
src="gen.jpg" name="Image13" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','hotels2.jpg',1)"><img
src="hotels.jpg" name="Image14" width="144" height="26" border="0"></a><br>
<a href="prop_other.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image15','','events2.jpg',1)"><img
src="events.jpg" name="Image15" width="144" height="26" border="0"></a><br>
</div>
<script type="text/javascript">
at_attach("menu6_parent", "menu6_child", "hover", "y", "pointer");
</script>
<div id="menu7_parent"
style="width: 59px; border:0px; padding: 0px 0px; float:left;">
<img src="contact.jpg"/>
</div>
</body>
</html>