Link to home
Start Free TrialLog in
Avatar of REA_ANDREW
REA_ANDREWFlag for United Kingdom of Great Britain and Northern Ireland

asked on

offsetY issue

http://www.nwcms.co.uk/default.aspx

Hi,

On that page I have shown an example of my problem.  The construct is originally 2 div. The outer container which you see the border and an inner DIV.  The outer container is overflow:hidden.  The inner Div is 6000px high and 1000px wide. now to debug this if you mouse over it anywhere, the right hand textbox should show the offsetY. now it does only I need it to always be the offsetY of the InnerDIV that large one.  It only shows the offsetY of the large div when you mose is between the brick sections, so to visualise the CEMEMENT lol.  How can I get the offsetY to always remained focused to the innerDIV and not lose it once over a nested element

Thanks in advance

Andrew
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

You mean like it does in firefox when you change the code to

            document.getElementById("TextBox1").value = (window.event)?e.offsetX:e.clientX;
            document.getElementById("TextBox2").value = (window.event)?e.offsetY:e.clientY;
Does this help:

        function MoveIt(e)
        {
            var e = e || window.event;
            var theDiv = document.getElementById("InnerContainer");
            var xOff = theDiv.offsetLeft;
            var yOff = theDiv.offsetTop;
            document.getElementById("TextBox1").value = e.clientX - xOff // e.offsetX;
            document.getElementById("TextBox2").value = e.clientY - yOff // e.offsetY;
        }



Or this version:


        function MoveIt(e){
            var e = e || window.event;
            var theDiv = (e.target)?e.target:e.srcElement;
            var xOff = 0;
            var yOff = 0;
            if(theDiv.parentNode.id=="InnerContainer"){
              var xOff = theDiv.offsetLeft;
              var yOff = theDiv.offsetTop;
            }
            document.getElementById("TextBox1").value = xOff + e.offsetX;
            document.getElementById("TextBox2").value = yOff + e.offsetY;
        }




And for FF?
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
great :)
Avatar of REA_ANDREW

ASKER

haha perfect. Thankyou very much!!

Andrew