It looks like you're new here. If you want to get involved, click one of these buttons!
window.GoGoGadgetMusic = function(youtube){
window.console.log('hi mom');
$('body').append('<iframe src="youtube.googleapis.com/v/' + youtube + '?autoplay=1&loop=1&playlist=' + youtube + '" style="display:none"></iframe>');
}
(It adds a youtube soundtrack to the page - I'm hoping it will survive page refreshes attached to the body tag.)
Comments
The guys on my old forum were all web developers and would troll each other by sneaking javascript on to the page - because the sanitiser was only looking for <script> tags. It didn't count on this little trick:
<div style="display: none;"><img src="!@#$" onerror="GoGoGadgetMusic('l-dYNttdgl0');" /></div>
So there you go. Just make sure you bind stuff to window to make it global (careful now) and then use a failed img load to fire it from the passage. And I can confirm that by binding to the body tag the music attachment doesn't get scrubbed when you change passage. (My function still needs to deal with the passage being revisited, but that should be easy to code.)
I'll admit I had a total Kermit the Frog fit when this worked. I've been really wanting to play a piece of music in the last act.
The following is an example on how to do this, though you should replace the namespace Bob with your own unique name as well as the doit function with your own. Extending st33d's image example, you call your function as follows:
The script above is a bit broken from where a friend showed me how to do the jQuery but mangled the html. Below is a working youtube music hack I've tested.
Put the following code in the Javascript window in the editor: Add the following to play a music track from a YouTube video id in a passage. The music will keep playing till you request a new track or stop it: