Links won't work! Help!

Discussion of javascript programming.

Links won't work! Help!

Postby kimballohara » Tue Jan 27, 2009 11:48 am

I'm using a multiple image rollover script combined with a drop-down menu. The image rollover works and the menu works, but clicking on the images doesn't result in a redirect--the user simply remains on the same page. In other words, the rollover and the drop-down menu work, but the link itself doesn't! Please help. Here's the script:

<style type="text/css">

#dropmenudiv{
position:absolute;
border:1px 8c0001;
border-bottom-width: 0;
font:normal 11px Verdana;
line-height:18px;
z-index:100;
}

#dropmenudiv a{
width: 100%;
display: block;
text-indent: 10px;
border-bottom: 1px solid black;
padding: 3px 0;
text-decoration: none;
background-color: 121212;
}

#dropmenudiv a:hover{ /*hover background color*/
background-color: bababa;
}

</style>

<script type="text/javascript">

/***********************************************
* AnyLink Drop Down Menu- &#169; Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var menu1=new Array()
menu1[0]='<a href="/">From Ocean to Sky</a>'
menu1[1]='<a href="/">Island Nation</a>'
menu1[2]='<a href="/">In Their Footsteps</a>'
menu1[3]='<a href="/">World by Water</a>'
menu1[4]='<a href="/">World by Land</a>'

var menu2=new Array()
menu2[0]='<a href="/features/0811-iran.shtml">Iran</a>'
menu2[1]='<a href="/">India-Tibet</a>'
menu2[2]='<a href="/">Puerto Rico</a>'
menu2[3]='<a href="/">Mt. Rainier</a>'
menu2[4]='<a href="/">Ethiopia</a>'
menu2[5]='<a href="/">Burma</a>'
menu2[6]='<a href="/">Mexico</a>'

var menu3=new Array()
menu3[0]='<a href="/deps/top7/0812.shtml">Top 7</a>'
menu3[1]='<a href="/deps/idiotsguide/0901.shtml">IGtA by Phil Guidry</a>'
menu3[2]='<a href="/">World A-Z</a>'
menu3[3]='<a href="/deps/otbt/0812.shtml">Off the Beaten Track</a>'
menu3[4]='<a href="/">Profiles in Adventure</a>'
menu3[5]='<a href="/">AJ Episodes</a>'
menu3[6]='<a href="/">Footsteps</a>'
menu3[7]='<a href="/">Journey Awards</a>'
menu3[8]='<a href="/">Journeyblog</a>'
menu3[9]='<a href="/deps">More...</a>'

var menu4=new Array()
menu4[0]='<a href="/">Adventure Finder</a>'
menu4[1]='<a href="/">Route Planner</a>'
menu4[2]='<a href="/">Language Learner</a>'

var menu5=new Array()
menu5[0]='<a href="/">Photos</a>'
menu5[1]='<a href="/">Videos</a>'
menu5[2]='<a href="/">Podcasts</a>'

var menuwidth='165px' //default menu width
var menubgcolor='lightyellow' //menu bgcolor
var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

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

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

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, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
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=ie4 && !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=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !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 populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
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 (ie4||ns6) 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 (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

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

if (hidemenu_onclick=="yes")
document.onclick=hidemenu

</script>


...And here's the code in the body of the page:


<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><a href="/expeditions" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu1, '133px')" onMouseout="delayhidemenu()"><img src="/images/b1-off.jpg" border="0" class="domroll /images/b1-on.jpg" /></a></td>
<td><a href="/features/0811-iran.shtml" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu2, '110px')" onMouseout="delayhidemenu()"><img src="/images/b2-off.jpg" border="0" class="domroll /images/b2-on.jpg" /></a></td>
<td><a href="/deps" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu3, '145px')" onMouseout="delayhidemenu()"><img src="/images/b3-off.jpg" border="0" class="domroll /images/b3-on.jpg" /></a></td>
<td><a href="/" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu4, '140px')" onMouseout="delayhidemenu()"><img src="/images/b4-off.jpg" border="0" class="domroll /images/b4-on.jpg" /></a></td>
<td><a href="/" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu5, '143px')" onMouseout="delayhidemenu()"><img src="/images/b5-off.jpg" border="0" class="domroll /images/b5-on.jpg" /></a></td>
<td><a href="/"><img src="/images/b6.jpg" border="0"></a></td>
</tr>
</table>

Any idea why the links ("/expeditions", for example) won't work?
Any help would be very appreciated.

Thanks!
kimballohara
 
Posts: 1
Joined: Tue Jan 27, 2009 11:41 am

Re: Links won't work! Help!

Postby Floydian » Wed Jan 28, 2009 12:09 am

I'm not sure. I do know that netscape 6 and IE 4 are soo out of the loop that I can't imagine why all that stuff is in the file. Almost noone uses those browsers anymore. That's like a less than 0.1% market share you're dealing with there.

anyways, to be frank, I don't quite understand the script.
User avatar
Floydian
Site Admin
 
Posts: 212
Joined: Fri Jul 18, 2008 8:39 pm


Return to Javascript Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron