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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:18:18+00:00 2026-05-28T01:18:18+00:00

I included a SVG file in my HTML document with <embed src=mySvg.svg /> and

  • 0

I included a SVG file in my HTML document with <embed src="mySvg.svg" /> and now I want to manipulate what is inside my SVG.

I found that the SVG is not in “document” but in “window”.

In my SVG file, I have a script :
(the init function in launch onload)
function init(evt) {
svgDocument = evt.target.ownerDocument;
svgDocument.getElementById('anIdOfMySvgFile'); // I successfully get the element of the SVG file
this.parent.document.getElementById('anIdOfMyHtmlFile'); // I successfully get the element of the HTML file
}

But how can I select an element from my SVG file with a script located in my HTML file ?
window.document is my HTML file … but I don’t know how my SVG file is identified !

  • 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-28T01:18:19+00:00Added an answer on May 28, 2026 at 1:18 am

    Set an ID on the embed, then use document.getElementById to grab it. Make sure to access the SVG through getSVGDocument().

    <embed src="mySvg.svg" id="mySvg" />
    
    <script type="text/javascript">
            var mySvg = document.getElementById("mySvg");
            mySvg.addEventListener("load", function() {
                var svg = mySvg.getSVGDocument();
                svg.getElementById("[insert svg element id here]");
            }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems that w3c supports the svg file format, however not all browsers support
I have an SVG file, and I don't want to paste it inside the
I have a stand-alone svg file that displays without problems. It includes some inline
There is a bug in Inkscape where JPEG images included in an SVG document
When an SVG is directly included in a document using the <svg> tag, you
I'm working on a report that includes an embedded svg diagram. The diagram is
I'm building a set of SVG files that include an unfortunate number of hardcoded
I included a repeater in my master page. The repeater has a button that
I've included a mobile web form in my asp.net project, I thought that it
I have included a resource in my Visual Studio 2005 solution that was a

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.