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 6618687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:52:02+00:00 2026-05-25T20:52:02+00:00

In have two div in the page,the outer and the inner. I bind the

  • 0

In have two div in the page,the outer and the inner.

I bind the mousemove event to the outer div,when user mousemove in the outer div,it will show the clientX and clientY of the mouse.

Also I make the inner div dragable,here is the live example.

1) I do not want the outer’s mousemove event trigger when I drag the inner div.

Of course I can set the “outer.onmousemove=null” when I drag the inner div,but I do not think it is the best way since the event on the outer div maybe binded by other people.

I try to use the event.cancalBubble,but it seems that it does not work.

2) when I drag the inner div,it will select the text in the firefox,how to stop it?

  • 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-25T20:52:03+00:00Added an answer on May 25, 2026 at 8:52 pm

    There are two functions that can be called to make sure that the event bubble stops:

    event.stopPropagation();
    event.preventDefault();
    

    If you make sure to call both of those then it should prevent both the parent div being selected and the text being selected.

    Edit:

    Looking more closely at your code I see a few problems. The first thing is that you use the onmousemove event for registering the mouse coordinates in the “outer” div. Then you use the documents onmousemove to drag to “inner” div around. That means that if you stop the propagation for the onmousemove event when you start dragging, it will never bubble up to the document node and in turn will result in the draggable div never being dragged untill you actually move the mouse outside the “inner” div area.

    One solution is to set the _mouseMove function on the moveable div instead of the document and then stop the propagation like this:

    /* Remove this */
    //document.onmousemove=_mouseMove;
    //document.onmouseup=_mouseUp;
    
    /* Add this */
    move_ele.onmousemove=_mouseMove;
    move_ele.onmouseup=_mouseUp;
    e.stopPropagation();
    e.preventDefault();
    

    This will make it work like you mention except when you drag so fast that the cursor leaves the “inner” div area, then it will stop dragging untill the cursor enters the div area again.

    Another solution is to handle it all in the “outer” divs onmousemove event to see if the mouse is actually moving over that div and not the “inner” like this:

    out.onmousemove=function(e){
        /* Check to see if the target is the "outer" div */
        if(e.target == this){
            e=e==null?window.event:e;
            note.innerHTML=e.clientX+','+e.clientY;
        }
    }
    

    This will also work like you mention but it will also stop the coordinates from being updated as soon as you move the cursor over the inner div even though you have not started dragging.

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

Sidebar

Related Questions

I have two elements on my page (two 'cancel' elements). <div unselectable=on class=x-grid-cell-inner x-unselectable
I have two divs, one inner and one outer, but the inner div is
I have a page with the following two divs: <div id=searchResults> </div> <div class=postSearchOptions
I have two div columns sidebar(left) and page-content(right). I toggle removing and adding 'sidebar'
I have two views in a Drupal page with the following structure: <div> <div>Some
I have a page with two div s on it which should fill the
Suppose I have two DIVs on my page. <body> <div id=d1></div> <div id=d2></div> </body>
I have two div element in my page aligned vertically. content of one div
i have two links <a href=page1.html>page 1</a> <a href=page2.html>page 2</a> <div id=content>&nbsp;</div> 1. I
I have two div tags - current page appears like ------------- <tag-1> <tag-2> ---------------

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.