Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. hide and show popup menu

hide and show popup menu

Scheduled Pinned Locked Moved ASP.NET
questiondatabasesysadmintutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abdul Rahman Hamidy
    wrote on last edited by
    #1

    Dear All, I have very simple statements which popsup a menu as bellow

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

    if (ie5||ns6)
    document.write('<div id="popitmenu"></div>')
    function showmenu(e, which, optWidth)
    {
    menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
    menuobj.innerHTML=which
    /*
    process links and others here then finaly display it
    */
    menuobj.style.visibility="visible";
    return false
    }
    function hidemenu()
    {
    var div = document.getElementById('popitmenu');
    if (div)
    div.style.visibility="hidden";
    }
    if (ie5||ns6)
    document.onclick=hidemenu;
    <body style="width:100%; height:100%">
    <form id="form1" runat="server">
    <div>
    <a id="a" onclick="return showmenu(event,linkset[1], '180px');">Click here</a>
    </div>
    </form>
    </body>

    every time i click on "Click here" which displays popupmenu it suddenly hides, I debugged the statements and I got that every time the function hidemenu() is executed. as I am assigning hidemenu function to body click event which means, If i click at body the popupmenu should hide, but the question is here, If i am clicking at "Click here" why the hidemenu is called, or how I can hide the popupmenu. simply, when I click at click here the popup should appear but when i am clicking at other places the popup should hide, how to achive it in above?

    Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

    S D 2 Replies Last reply
    0
    • A Abdul Rahman Hamidy

      Dear All, I have very simple statements which popsup a menu as bellow

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

      if (ie5||ns6)
      document.write('<div id="popitmenu"></div>')
      function showmenu(e, which, optWidth)
      {
      menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
      menuobj.innerHTML=which
      /*
      process links and others here then finaly display it
      */
      menuobj.style.visibility="visible";
      return false
      }
      function hidemenu()
      {
      var div = document.getElementById('popitmenu');
      if (div)
      div.style.visibility="hidden";
      }
      if (ie5||ns6)
      document.onclick=hidemenu;
      <body style="width:100%; height:100%">
      <form id="form1" runat="server">
      <div>
      <a id="a" onclick="return showmenu(event,linkset[1], '180px');">Click here</a>
      </div>
      </form>
      </body>

      every time i click on "Click here" which displays popupmenu it suddenly hides, I debugged the statements and I got that every time the function hidemenu() is executed. as I am assigning hidemenu function to body click event which means, If i click at body the popupmenu should hide, but the question is here, If i am clicking at "Click here" why the hidemenu is called, or how I can hide the popupmenu. simply, when I click at click here the popup should appear but when i am clicking at other places the popup should hide, how to achive it in above?

      Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      Abdul Rahman Hamidy wrote:

      If i am clicking at "Click here" why the hidemenu is called, or how I can hide the popupmenu.

      Because, Click here is a part of the page body (its in it!)

      Abdul Rahman Hamidy wrote:

      simply, when I click at click here the popup should appear but when i am clicking at other places the popup should hide, how to achive it in above?

      On body click, call a javascript method where you can check if the click was on 'Click Here' div tag, if so, dont do anything or else hide it.

      1 Reply Last reply
      0
      • A Abdul Rahman Hamidy

        Dear All, I have very simple statements which popsup a menu as bellow

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

        if (ie5||ns6)
        document.write('<div id="popitmenu"></div>')
        function showmenu(e, which, optWidth)
        {
        menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
        menuobj.innerHTML=which
        /*
        process links and others here then finaly display it
        */
        menuobj.style.visibility="visible";
        return false
        }
        function hidemenu()
        {
        var div = document.getElementById('popitmenu');
        if (div)
        div.style.visibility="hidden";
        }
        if (ie5||ns6)
        document.onclick=hidemenu;
        <body style="width:100%; height:100%">
        <form id="form1" runat="server">
        <div>
        <a id="a" onclick="return showmenu(event,linkset[1], '180px');">Click here</a>
        </div>
        </form>
        </body>

        every time i click on "Click here" which displays popupmenu it suddenly hides, I debugged the statements and I got that every time the function hidemenu() is executed. as I am assigning hidemenu function to body click event which means, If i click at body the popupmenu should hide, but the question is here, If i am clicking at "Click here" why the hidemenu is called, or how I can hide the popupmenu. simply, when I click at click here the popup should appear but when i am clicking at other places the popup should hide, how to achive it in above?

        Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

        D Offline
        D Offline
        daveyerwin
        wrote on last edited by
        #3

        Here is a simple example which i believe accomplishes what you want ...

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
        <html>
        <head>
        <script>

        linkset = new Array("hiyas","sup");

        showmenu = function(thiss){
        pop = document.getElementById("popmenu");
        pop.innerHTML = "px = "+ thiss.px + " link = " + linkset[thiss.link]
        pop.style.visibility = 'visible';

        }
        hide = function(e){
        if(e){
        id = e.target.id}
        else{
        id = event.srcElement.id}
        if(id !="show"){
        document.getElementById("popmenu").style.visibility = 'hidden';}
        }

        document.onclick=hide;
        </script></head>
        <body>

        <form id="form1" runat="server">
        <div>
        <a id="show"  onclick="this.px='180px';this.link='1';showmenu(this)" >
        Click here
        	</a><br>
        <a id="show"  onclick="this.px='90px';this.link='0';showmenu(this)" >
        Click here
        	</a>
        <div id="popmenu">Hello Im a menu</div>	
        </div>
        </form>
        
        </body>
        </html>
        
        A 1 Reply Last reply
        0
        • D daveyerwin

          Here is a simple example which i believe accomplishes what you want ...

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
          "http://www.w3.org/TR/html4/strict.dtd">
          <html>
          <head>
          <script>

          linkset = new Array("hiyas","sup");

          showmenu = function(thiss){
          pop = document.getElementById("popmenu");
          pop.innerHTML = "px = "+ thiss.px + " link = " + linkset[thiss.link]
          pop.style.visibility = 'visible';

          }
          hide = function(e){
          if(e){
          id = e.target.id}
          else{
          id = event.srcElement.id}
          if(id !="show"){
          document.getElementById("popmenu").style.visibility = 'hidden';}
          }

          document.onclick=hide;
          </script></head>
          <body>

          <form id="form1" runat="server">
          <div>
          <a id="show"  onclick="this.px='180px';this.link='1';showmenu(this)" >
          Click here
          	</a><br>
          <a id="show"  onclick="this.px='90px';this.link='0';showmenu(this)" >
          Click here
          	</a>
          <div id="popmenu">Hello Im a menu</div>	
          </div>
          </form>
          
          </body>
          </html>
          
          A Offline
          A Offline
          Abdul Rahman Hamidy
          wrote on last edited by
          #4

          Thank you very much, the hide function could do the work.

          Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

          D 1 Reply Last reply
          0
          • A Abdul Rahman Hamidy

            Thank you very much, the hide function could do the work.

            Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

            D Offline
            D Offline
            daveyerwin
            wrote on last edited by
            #5

            Abdul Rahman Hamidy wrote:

            Thank you very much, the hide function could do the work.

            You are most welcome.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups