Take a look at
http://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#SVG_in_HTML .
This was written pre-IE9, so the stated preference for <embed> over <object>
would now be reversed. Scripting between HTML and SVG, though, is pretty
much the same whether using embed, iframe or object.

 

Examples are given for interacting in both directions between scripts that
reside in SVG and in HTML.

 

Cheers

David

From: [email protected] [mailto:[email protected]]
On Behalf Of dark3251
Sent: Tuesday, September 06, 2011 12:17 PM
To: [email protected]
Subject: [svg-developers] Access parent DOM through script in embedded SVG

 

  

I am working on an SVG web application that I am embedding into an HTML5
page. The SVG doc has its own script that performs operations on the entire
page. For the sake of example, I will show what I would like to accomplish
using the HTML5 <audio> tag. Interacting with this element is cake if I
embed the SVG doc directly into the HTML of the page, it's as simple as
accessing the DOM through JavaScript. However, I would like to get this app
to a point where it is placed into the page with an <embed> tag. 

I know that an embedded Flash/AS can access the page's DOM through the
ExternalInterface class so I would imagine there is a way to do so using
pure JavaScript as well. The embedded SVG will always be on the same domain
so there should not be any security issues. Any help with finding a solution
to this would be appreciated.

Here is some code to show what I mean (I have left out namespaces and such
to simplify):

The SVG:
<svg>
<script type="text/javascript">
//the audio element on the page
var audio = document.getElementById('theAudio');

//a function to instruct the audio element to play
function playAudio() {
audio.play();
}
</script>

<!-- A button to play the audio when clicked -->
<rect x="0" y="0" width="50px" height="50px" fill="black"
onclick="playAudio()" />
</svg>

The HTML:
<div>
<!-- The embedded SVG doc -->
<embed src="play_audio.svg" type="image/svg+xml" />
</div>

<!-- The Audio element -->
<audio id="theAudio" src="sound.wav" preload="auto">
Your browser does not support HTML5 audio.
</audio>





[Non-text portions of this message have been removed]



------------------------------------

-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to