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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:04:18+00:00 2026-06-05T16:04:18+00:00

I had created one div window which is draggable,and created one child div (with

  • 0

I had created one div window which is draggable,and created one child div (with in the window div) which is scrollable.Those work individually fine,but when I am trying to scroll the inner div by clicking on up and down arrow of scroll, the drag event is triggered once scrolling has been finished.I am not able to solve the issue….Any suggestions please…

Here is the code…

<!DOCTYPE HTML>
    <HTML>
    <HEAD>
    <TITLE> Reporting</TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    <style>
    body{
    font-family:Arial,Helvetica,sans-serif;
    font-size:0.7em;
    }
    .Object{
    width:190px;
    height:100px;
    border:1px solid black;
    border-radius:7px 7px 7px 7px;
    box-shadow:3px 3px 2px #D2D2D2;
    position:absolute;
    resize:
    }

    .ObjHdr{
     color:#fff;
     background:#363636; 
     padding:3px 0px 3px 7px;
     border-radius:6px 6px 0px 0px;;
     font-weight:bold;
     cursor:move;
    }

    .ObjBody{
     width:190px;
     height:77px;
     overflow:scroll;
    }

    .ObjEle{
     padding:1px 0px 1px 4px;
     color:#000;
     border-bottom:1px solid black;
     cursor:pointer;
    }

    </style>

    </HEAD>
    <BODY>

     <div id="ObjCountry" class="Object">
       <div class="ObjHdr">Country</div>
       <div id =sd class="ObjBody" unselectable="on">
        <div class="ObjEle">India</div>
        <div class="ObjEle">China</div>
        <div class="ObjEle">USA</div>
        <div class="ObjEle">Iran</div>
        <div class="ObjEle">Iraq</div>
        <div class="ObjEle">Indonesia</div>
       </div>
     </div>

    </BODY>
    </HTML>

    <script>

    var DragHandler = {

        // private property.
        _oElem : null,

        // public method. Attach drag handler to an element.
        attach : function(oElem) {
            oElem.onmousedown = DragHandler._dragBegin;

            // callbacks
            oElem.dragBegin = new Function();
            oElem.drag = new Function();
            oElem.dragEnd = new Function();

            return oElem;
        },

        // private method. Begin drag process.
        _dragBegin : function(e) {
            var oElem = DragHandler._oElem = this;

            if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; }
            if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '0px'; }

            var x = parseInt(oElem.style.left);
            var y = parseInt(oElem.style.top);

            e = e ? e : window.event;
            oElem.mouseX = e.clientX;
            oElem.mouseY = e.clientY;

            oElem.dragBegin(oElem,x,y);

            //document.onmousemove = DragHandler._drag;
            document.onmouseup = DragHandler._dragEnd;
            oElem.onmousemove = DragHandler._drag;
            oElem.onmouseup = DragHandler._dragEnd;
            return false;
        },

        // private method. Drag (move) element.
        _drag : function(e) {
            var oElem = DragHandler._oElem;

            var x = parseInt(oElem.style.left);
            var y = parseInt(oElem.style.top);

            e = e ? e : window.event;

            var tmpX = x + (e.clientX - oElem.mouseX);
            var tmpY = y + (e.clientY - oElem.mouseY);

            if(tmpX<=0){tmpX = 0;}
            if(tmpY<=0){tmpY = 0;}


            oElem.style.left = tmpX + 'px';
            oElem.style.top  = tmpY + 'px';

            oElem.mouseX = e.clientX;
            oElem.mouseY = e.clientY;

            oElem.drag(oElem, x,y);

            return false;
        },

        // private method. Stop drag process.
        _dragEnd : function() {
            var oElem = DragHandler._oElem;

            var x = parseInt(oElem.style.left);
            var y = parseInt(oElem.style.top);

            oElem.dragEnd(oElem, x, y);

            oElem.onmousemove = null;
            oElem.onmouseup = null;
            document.onmousemove=null;
            document.onmouseup=null;
            DragHandler._oElem = null;

        }

    }

    DragHandler.attach(document.getElementById('ObjCountry'));

    </script>
  • 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-05T16:04:19+00:00Added an answer on June 5, 2026 at 4:04 pm

    I would made it as follows:

    -create a new method in draghandler which calls only the dragend private method
    -create a mousedown event to id=”ObjHdr” – it starts the dragging
    -create a mouseup event to id=”ObjHdr” – it ends the dragging

    into draghandler:
    detach: function(oElem) {oElem.onmousedown = DragHandler._dragEnd; return oElem; },

    document.getElementById(“ObjHdr”).onmousedown=”DragHandler.attach(document.getElementById(“ObjCountry”));”
    document.getElementById(“ObjHdr”).onmouseup=”DragHandler.detach(document.getElementById(“ObjCountry”));”

    result:
    Drag-drop event starts only if you click on the header and ends on mouseup.
    No action if you try to click on “ObjBody” – no dragprocess will start..

    regards
    Ozsi

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

Sidebar

Related Questions

I had created one HTML page for my experiance. In this i had use
i had created a class with two properties one of datetime datatype and other
In one of my builds for an iPhone app, I had inadvertently created a
I have created an app in which I had use SPenSDK to create image
Hi am newbie to android development. I had created one application where i need
In school, one of my professors had created a 3D game (not just an
I had created a framework for a project in the past that one of
Im new to selenium and was trying to delete some contacts which i had
I had created a zip file (together with directory) under Windows as follow (Code
I have a smallish utility library I made that I had created in TFS

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.