PDA

View Full Version : Problem with Pop-it menu script



mkg
02-26-2012, 05:33 PM
1) Script Title:
Pop-it menu

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

3) Describe problem:
Can you tell me how I can alter the script so that the menu does not float with the mouse but just drops straight down from the bottom of the tab?

code:


/***********************************************
* Pop-it menu- Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var defaultMenuWidth="180px" //set default menu width.

var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT

linkset[0]='<a href="about.htm">About Our Agency</a>'
linkset[0]+='<a href="services.htm">Services & Products</a>'
linkset[0]+='<a href="companies.htm">Our Companies</a>'
linkset[0]+='<a href="quote.htm">Get-a-Quote</a>'



linkset[1]='<a href="contact.htm">Contact Us</a>'
linkset[1]+='<a href="claims.htm">Report a Claim</a>'
linkset[1]+='<a href="payment.htm">Payments</a>'
linkset[1]+='<a href="personal_lines.htm">Personal Lines Forms</a>'
linkset[1]+='<a href="companies.htm">Companies Represented</a>'
linkset[1]+='<a href="registry.htm">In House Registry Service</a>'
linkset[1]+='<a href="information.htm">Information</a>'
linkset[1]+='<a href="quote.htm">Get-a-Quote</a>'

linkset[2]='<a href="personal.htm">Personal Insurance</a>'
linkset[2]+='<a href="products.htm">Products</a>'
linkset[2]+='<a href="discounts.htm">Discounts</a>'
linkset[2]+='<a href="companies.htm">Our Companies</a>'
linkset[2]+='<a href="personal_lines.htm">Forms/Resources</a>'
linkset[2]+='<a href="quote_other.html">Get-a-Quote</a>'

linkset[3]='<a href="companies.htm">Our Companies</a>'
linkset[3]+='<a href="certificate.htm">Certificate Request</a>'
linkset[3]+='<a href="quote_other.html">Get-A-Quote</a>'

////No need to edit beyond here

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

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenu(e, which, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=which
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}

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

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

if (ie5||ns6)
document.onclick=hidemenu

</script>

ddadmin
02-27-2012, 06:33 AM
In that case take a look at the following two menu scripts instead:

http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm
http://www.dynamicdrive.com/dynamicindex1/flexdropdown.htm

mkg
02-29-2012, 01:50 AM
Thank you!! The Flex Drop Down Menu solved my problem. I am grateful for this help!!!