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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:27:07+00:00 2026-05-27T15:27:07+00:00

I have got a html page embedded with a .svg. I have written most

  • 0

I have got a html page embedded with a .svg. I have written most of the logic in java script and would like to share the same .js between html and .svg file:

for ex: I have got the following in mylogic.js:

var xmlDoc = null;
function loadXmlDoc() {
   xmlDoc = new XmlDoc.....
}

function onHtmlLoad() {
   loadXmlDoc();
}

function onSvgLoad() {
   xmlDoc.getElemementById(...
}`

and in the Html, I have got

<html>
<script src="mylogic.js"></script>
<body onLoad='onHtmlLoad();">
...
<object id='svgid' data='sample.svg'.../>
...
</body>
</html>

and the java script included in the html page is not visible in the embedded .svg file so I have to include them again like…

<svg...onload="window.onSvgLoad();">
<script xlink:href="mylogic.js></script>
</svg>

since I included the .js file twice, I am getting the xmlDoc as null inside onSvgLoad() function. I believe, there should be a way to get the same instance of xmlDoc loaded from html in svg. but I am not getting it..?

alternatively I tried not to include .js file in svg instead tried changing onload to onload=”window.top.onSvgLoad();” ; then to onload=”window.parent.onSvgLoad();” but still did not work!
*Please note that I am using IE9 with its native support for Html5.

  • 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-27T15:27:08+00:00Added an answer on May 27, 2026 at 3:27 pm

    javascript included in the html page IS visible from the embedded .svg file. Remove the script tag from the embedded svg and call the methods you want as parent.method e.g. if mylogic.js had

    function hello()
    {
        return "hello";
    }
    

    you could write

    <script>
      alert(parent.hello());
    </script>
    

    in the embedded .svg file to call it.

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

Sidebar

Related Questions

I have the following script inside a HTML page: <script> function Test(){ alert(i got
I have got a PHP/HTML page where I want to fetch data from but
I have got a html web page which gets a user input in the
I have 5 div's in my html page and 5 buttons.I want to got
I wasn't sure about my questions name. I have an HTML page I got
We have got an extjs 3.1.1 form with file upload field ( http://www.extjs.com/deploy/dev/examples/form/file-upload.html from
I have got a python script which is creating an ODBC connection. The ODBC
So I have a html page that has a form, and a table inside
I got a HTML/PHP5 page with a form, then when it gets posted, it
I have to keep the formatting the exact same way that I got this

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.