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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:17:27+00:00 2026-05-22T02:17:27+00:00

I’m performing maintenance on some javascript which makes use of the .offsetParent property. Recent

  • 0

I’m performing maintenance on some javascript which makes use of the .offsetParent property. Recent changes now have the application using SVG elements, and they are breaking the JavaScript, as mySvgElement.offsetParent is always undefined.

Is .offsetParent standard, and does it not work with SVG elements? If so, what is an alternative to .offsetParent when working with HTML5 SVG elements?

  • 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-22T02:17:28+00:00Added an answer on May 22, 2026 at 2:17 am

    offsetParent does not exist in SVG.

    To get the bounding box coordinates of an SVG node, you would typically use the getBBox method on the SVG element. This returns a bbox in the local coordinate system of that element. To determine the location of the SVG element in screen coordinates, then, you use getScreenCTM on the element to get a transformation matrix that will transform that element’s local coordinates to screen coordinates. You then transform the returned bbox by the returned transformation matrix. Here’s some code to do this:

    function getBoundingBoxInArbitrarySpace(element,mat){
        var svgRoot = element.ownerSVGElement;
        var bbox = element.getBBox();
    
        var cPt1 =  svgRoot.createSVGPoint();
        cPt1.x = bbox.x;
        cPt1.y = bbox.y;
        cPt1 = cPt1.matrixTransform(mat);
    
        // repeat for other corner points and the new bbox is
        // simply the minX/minY  to maxX/maxY of the four points.
        var cPt2 = svgRoot.createSVGPoint();
        cPt2.x = bbox.x + bbox.width;
        cPt2.y = bbox.y;
        cPt2 = cPt2.matrixTransform(mat);
    
        var cPt3 = svgRoot.createSVGPoint();
        cPt3.x = bbox.x;
        cPt3.y = bbox.y + bbox.height;
        cPt3 = cPt3.matrixTransform(mat);
    
        var cPt4 = svgRoot.createSVGPoint();
        cPt4.x = bbox.x + bbox.width;
        cPt4.y = bbox.y + bbox.height;
        cPt4 = cPt4.matrixTransform(mat);
    
        var points = [cPt1,cPt2,cPt3,cPt4]
    
        //find minX,minY,maxX,maxY
        var minX=Number.MAX_VALUE;
        var minY=Number.MAX_VALUE;
        var maxX=0
        var maxY=0
        for(i=0;i<points.length;i++)
        {
            if (points[i].x < minX)
            {
                minX = points[i].x
            }
            if (points[i].y < minY)
            {
                minY = points[i].y
            }
            if (points[i].x > maxX)
            {
                maxX = points[i].x
            }
            if (points[i].y > maxY)
            {
                maxY = points[i].y
            }
        }
    
        //instantiate new object that is like an SVGRect
        var newBBox = {"x":minX,"y":minY,"width":maxX-minX,"height":maxY-minY}
        return newBBox; 
    }   
    
    function getBBoxInScreenSpace(element){
        return getBoundingBoxInArbitrarySpace(element,element.getScreenCTM());
    }
    

    This code was taken from here, and is Apache-licensed. getBoundingBoxInArbitrarySpace has been tested, but getBBoxInScreenSpace hasn’t (but I think it should work).

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the

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.