Current location: Hot Scripts Forums » General Web Coding » JavaScript » dropdown menu problem


dropdown menu problem

Reply
  #1 (permalink)  
Old 05-19-06, 10:33 AM
gigafare gigafare is offline
Newbie Coder
 
Join Date: Oct 2005
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
dropdown menu problem

I have a dynamic admin where i can create pages and subpages. Links from those pages are shown in a menu. For comfort reason the admin allows creating pages without displaying the link in the menu.
But here's the problem. I create a page and say "do not show link" in the menu, works fine, but if i thereafter edit and "show link in menu" it shows the link but when scrolling over it gives an error.

It's more than annoying because the rollout menu (from the subpages) doesn't work after scrolling over a link that was previously invisible.

Web site: http://www.immermoens.be/

HEADER:

Code:
<html>
<head>
<title>{$page_title}</title>
<link href="style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="anylink.css" />
<script type="text/javascript" src="anylink.js"></script>
</head>
<body>

<table width="960px" height="70px" cellspacing="0" cellpadding="0">
<tr><td><img src="img/header.gif"></td></tr>
</table>

<table width="960px" height="21px" cellspacing="0" cellpadding="0">
<tr>
<td background="img/categorie_bg.jpg">
<ul id="tablist">
<li><a href="index.php">Home</a></li>
{section name=p loop=$pages}
<li><a href="page.php?ID={$pages[p].ID}"  onMouseover="dropdownmenu(this, event, 'anylinkmenu{$smarty.section.p.iteration}')">{$pages[p].name}</a></li>
{/section}
</ul>
</td>
</tr>
</table>
<table width="960px" height="17px" cellspacing="0" cellpadding="0">
<tr>
<td background="img/subcategorie_bg.jpg">
{section name=p loop=$pages}
{if $pages[p].subpages}
<div id="anylinkmenu{$smarty.section.p.iteration}" class="anylinkcss">
{section name=sp loop=$pages[p].subpages}
<a href="page.php?ID={$pages[p].subpages[sp].ID}">{$pages[p].subpages[sp].name}</a>
{/section}
</div>
{/if}
{/section}

</td>
</tr>
</table>
JavaScript:

Code:
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prozilla Links Script Dropdown Menu IDEASGirl PHP 7 07-22-05 11:17 PM
Xml / Dom / Css Mark_SC.SE JavaScript 0 06-29-05 08:05 AM
MySQL Field Names into PHP Dropdown Menu KaraJ PHP 4 06-14-05 09:28 AM
mouseover effect in dropdown menu spyder1218 JavaScript 0 09-08-04 09:51 AM
drop down menu problem !!! nurqeen PHP 1 02-08-04 08:07 PM


All times are GMT -5. The time now is 11:09 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.