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>
------------------------------------
-----
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/