javascript - How to call functions defined in parent document from an svg referenced by an <object> element? -


i used embed svg file webpage:

    <object id="svgmap" width="100%" height="100%" data="<%=path %>/svg/map.svg" type="image/svg+xml" style="">     </object> 

and added images tags svg file using external javascript file called "support.js":

    var marker = document.createelementns(xmlns, 'image');     marker.setattributens(null, 'id', "img_0123");     marker.setattributens('http://www.w3.org/1999/xlink', 'href', iconurl);     marker.setattributens(null, 'x', posx);     marker.setattributens(null, 'y', posy);     marker.setattributens(null, 'visibility', 'visible');     marker.setattribute("onclick", "onsel('0123')"); 

this "onsel" function defined in support.js well, when clicked on image, changes image. when viewed page in browsers (opera, mozilla , chrome), didn't swap image when clicked on image, , in developer tool's console, said "referenceerror: onsel not defined svgmap:1".

does mean svg files cannot use functions defined in other javascript files? how that?

i've interpreted question "how call functions defined in scope of parent html document svg referenced <object> element?". it's little unclear question "onsel" function defined, i'm guessing it's in script inside html document.

here's example of how call inside svg out parent. function in parent prints element clicked , element referenced from.

from svg parent document:

    window.parent.yourfunctioninparentdocument(); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -