Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9163257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:24:13+00:00 2026-06-17T14:24:13+00:00

I was using this solution to hide divs on middle mousclick, but now I

  • 0

I was using this solution to hide divs on middle mousclick, but now I need to include it inside a plain debug script where no jQuery is available ( and never will ).

How can I write that event and bind with plain javascript?

I was searching google and SO, but only working scripts I got, where all jQuery based.


Final code:

<script type="text/javascript">
    function hideOnMiddle(event) {
        if ('which' in event) {
            if( event.which == 2 ) {
                document.getElementById('test').style.display = 'none'; 
            }
        }
    }
</script>
<div id="test" onmousedown="hideOnMiddle(event);">Hide me with middle mouse button</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:24:14+00:00Added an answer on June 17, 2026 at 2:24 pm

    Take a look at this: http://help.dottoro.com/ljwcseaq.php (Example HTML code 3) (jsFiddle)

    <head>
        <script type="text/javascript">
            function WhichButton (event) {
                    // all browsers except IE before version 9
                if ('which' in event) {
                    switch (event.which) {
                    case 1:
                        alert ("Left button is pressed");
                        break;
                    case 2:
                        alert ("Middle button is pressed");
                        break;
                    case 3:
                        alert ("Right button is pressed");
                        break;
                    }
                }
                else {
                        // Internet Explorer before version 9
                    if ('button' in event) {
                        var buttons = "";
                        if (event.button & 1) {
                            buttons += "left";
                        }
                        if (event.button & 2) {
                            if (buttons == "") {
                                buttons += "right";
                            }
                            else {
                                buttons += " + right";
                            }
                        }
                        if (event.button & 4) {
                            if (buttons == "") {
                                buttons += "middle";
                            }
                            else {
                                buttons += " + middle";
                            }
                        }
                        alert ("The following buttons are pressed: " + buttons);
                    }
                }
            }
        </script>
    </head>
    <body>
        <div onmousedown="WhichButton (event);">Press a mouse button over this text!</div>
    </body>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm considering using this jquery utility as a possible solution, but I want to
I am using this solution to have multiple tabs in one page . $(.tab_content).not(':first-child').hide();
i am using the Toxi solution on this site for tagging bookmarks: http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html In
I'm using Alberto Santini's solution to this question to get a spiral grid reference
Im pretty sure this has a simple solution. I am using jCarousellite, and i
I've got a set of side by side divs (actually using HTML5 sections but
I need a solution to hide/show a checkbox depending a radio button selection. I
I'm using this example: https://github.com/tciuro/CustomTabBar for a tabbar. I'm trying to hide it with
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using this to load the json var jsonParsed = JSON.parse(localStorage.getItem('test')); Using this to save

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.