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

  • Home
  • SEARCH
  • 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 6151933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:50:31+00:00 2026-05-23T19:50:31+00:00

I have a div with an onmousedown event, but it is triggering when I

  • 0

I have a div with an onmousedown event, but it is triggering when I click far outside of the div.
This screenshot shows where I had just clicked and registered a mousedown on the square. I think I have it obsessively annotated enough to be helpful… though I accidentally wrote “Picker” instead of “Switcher”… I have confirmed that “Picker” is no where in my code.

If you look on the page, active on my server you can duplicate this yourself. It doesn’t happen all the time, but OFTEN. The div on the right fills with one letter per event that is triggered and not cancelled for one reason or another, which I used to diagnose the problem.

I’m a new user (sory – new in general, so haven’t answered or asked anything) so can’t post images.
Edit: Here’s the image:

enter image description here

#colourSwitcherMapBox {
  position: absolute;
  left: 5px;
  top: 5px;
  height: 256px;
  width: 256px;
  display: block;
  background-color: orange;
}
#colourSwitcherMapMark {
  position: absolute;
  height: 15px;
  width: 15px;
  top: -8px;
  left: 248px;
  z-index: 3;
  display: block;
}
#colourSwitcherMapBox div {
  position: absolute;
  height: 256px;
  width: 256px;
  top: 0;
  left: 0;
}

<div id="colourSwitcherContainer" class="colourSwitcherStuff" onmousedown="colourSwitcherDrag(event);">
  Colour Switcher:<input type="checkbox" onclick="toggleColourSwitcher(this.checked);" />
  <div id="mainColourSwitcher">
    <div id="colourSwitcherMapBox" onmousedown="colourSwitcherDragMap(event);">
      <div id="colourSwitcherMapMark"><img src="imagesCP/mapIndicator.png" alt="" /></div>
      <div id="colourSwitcherMaxB"><img src="imagesCP/map-blue-max.png" alt="" /></div>
      ... lots more divs identical to the last line other than image and  ...
    </div>
   ... other stuff (colourSwitcherBarBox and colourSwitcherPickInfo) ...
  </div>
</div>

function colourSwitcherDragMap (event) {
  if (!event) {var event = window.event;}
  if (event.preventDefault) {event.preventDefault();} else { event.returnValue = false; }
  document.body.onmousemove = colourSwitcherChangeBar;
  document.body.onmouseup = colourSwitcherStopDragging;
  document.getElementById("randomblob").innerHTML += "M ";
  colourSwitcherChangeBar (event);
}
  • 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-05-23T19:50:32+00:00Added an answer on May 23, 2026 at 7:50 pm

    colourSwitcherMapMark accidentally picks up a height and width of 256px from this rule:

    #colourSwitcherMapBox div {
        height: 256px;
        ...
    

    making it much bigger than it needs to be. So if the marker is nearer the bottom of the colour area, it will hang over the edge of the colourSwitcherContainer and pick up clicks. I don’t think you intended this rule to match the MapMark; you will have to make it more specific, to only pick up the main div you want it to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have div(box) on my page and I'm using this script to display div
I have something similar to the following: <div onclick=divClickEvent();> <img onmousedown=imgOnDownEvent(); /> </div> The
I have markup like this <div id=colorpicker-background> <div id=colorpicker-selector></div> </div> With JS like this:
My problem is this: I have div with a background image, the opacity is
I have div containing a list of flash objects. The list is long so
I have a div and an iframe on the page the div has z-index:
I have a div in which a page is loaded with the DojoX Layout
I have a div with overflow:hidden , inside which I show a phone number
I have a div with a <h1> tag in a div, with no margins.
I have a div container and have defined its style as follows: div#tbl-container {

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.