Solved

Quick menu through Javascript

Posted on 2004-10-10
1
273 Views
Last Modified: 2008-03-03
Hi,

   I have used the following code to create a quick menu and scroll the quick menu when i scroll the browser. when i scroll down the menu the menu is getting scrolled but when i click on the menu it is taking back to the first postion and the menu is getting out of the browser.

Code is as follows:

<html>
<head>
<style type="text/css">
                  #menu1 { LEFT: -1000px; POSITION: absolute }
                  #menu2 { LEFT: -1000px; POSITION: absolute }
                  #menu3 { LEFT: -1000px; POSITION: absolute }
                  .baseline { FONT-SIZE: 9pt; LEFT: 250px; COLOR: #000000; FONT-FAMILY: Arial; POSITION: absolute; TOP: 100px }
</style>


</head>
<script language="javascript">
var siteLink = new Array();

siteLink[0] = "PopupDiagnosis.aspx";
siteLink[1] = "PopupInsurance.aspx";
siteLink[2] = "PopupPhysician.aspx";
siteLink[3] = "popupSupplies.aspx";
siteLink[4] = "popupletters.aspx";
siteLink[5] = "popupnotes.aspx";

var menu3top=195
var menuleft=-120
var pace=15

var step
var direction
var pause=75

var thismenu

var vorzeichen=1

var vorzeimenu3=-1

var menuismoving="no"


var scrollidx = 0
onscroll=function()
{
     var e = document.all.menu;
     if (document.body.scrollTop>195)
     {
               e.style.pixelLeft=document.body.clientWidth + document.body.scrollLeft - e.offsetWidth;
               e.style.pixelTop=document.body.scrollTop;
          document.all.menu.style.posLeft=menuleft;
     }
}



function inite()
{

      if (document.layers)
      {
        document.menu.left=menuleft
        document.menu.top=menu3top
      }
      if (document.all)
      {
        document.all.menu.style.posLeft=menuleft
        document.all.menu.style.posTop=menu3top
      }
}

function getmenuname(clickedmenu)
{
      thismenu=eval("document.all."+clickedmenu+".style")
    if (menuismoving=="no")
    {
          if (document.layers)
          {
            thismenu=eval("document."+clickedmenu)
          }
          if (document.all)
          {
            thismenu=eval("document.all."+clickedmenu+".style")
          }

        step=pace
        checkdirection()
          movemenu()
    }
}


function checkdirection()
{
      if (document.layers)
      {
        if (thismenu==document.menu){vorzeimenu3=vorzeimenu3*-1;vorzeichen=vorzeimenu3;}
      }
      if (document.all)
      {
        if (thismenu==document.all.menu.style)
        {
                  vorzeimenu3=vorzeimenu3*-1;vorzeichen=vorzeimenu3;
                  alert(vorzeimenu3 + "    "  + document.all.menu.style.left)
        }
      }
}


function movemenu()
{
      if (document.layers)
      {
        if (step>=0) {
            thismenu.left+=step*vorzeichen
            step--
            var movetimer=setTimeout("movemenu()",pause)
          }
        else {
            menuismoving="no"
            clearTimeout(movetimer)
        }
      }
      if (document.all)
      {

        if (step>=0)
        {
                        thismenu.posLeft+=step*vorzeichen
                        step--
                        var movetimer=setTimeout("movemenu()",pause)
          }
        else
            {
            menuismoving="no"
            clearTimeout(movetimer)
        }
    }
}

</script>


<body>

                  <img src="addmenubtn.gif" border="0" usemap="#Map">
                  <map name="Map">
                        <area shape="RECT" coords="120,4,135,129" onclick ="getmenuname('menu')"  HREF="#">
                        <area shape="RECT" coords="11,9,119,25" onClick="" href="#">
                        <area shape="RECT" coords="11,27,119,43" onClick="" href="#">
                        <area shape="RECT" coords="11,49,119,63" onClick="" href="#">
                        <area shape="RECT" coords="11,68,119,85" onClick="" href="#">
                        <area shape="RECT" coords="11,88,119,103" onClick="" href="#">
                        <area shape="RECT" coords="11,107,119,126" onClick="" href="#">
                        <area shape="RECT" coords="1,1,132,9" href="#">
                        <area shape="RECT" coords="4,125,136,132" href="#">
                  </map>

<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>

</body>
</html>


help me to solve this problem suggestion me where exactly i have gone wrong.

Thanx
0
Comment
Question by:mohan21_kumar
1 Comment
 
LVL 8

Accepted Solution

by:
tomvergote earned 25 total points
Comment Utility
<area shape="RECT" coords="11,9,119,25" onClick="" href="#">

I think the problem is with the > href="#" <
clicking a href="#" link sends the page back to the top.

you should be able to solve it by putting return false at the end of your onclick stuff.
onClick="return false"

I suppose you still have to write a click function which redirects and stuff so your code would go like:
function handleclick()
{
document.location.href=siteLink[0] ;
return false;
}

The return false should prevent the click from executing the href action.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now