Wait for iframe to load before next function is triggered?
<p>First off: I know things should be run asynchronously if possible.</p>

<p>I have a function, called wrap:</p>

<p>essentially it loads the current page as an iframe. I need it in order to keep the javascript running even when links are clicked on the page.</p>

<pre><code>function wrap(){
    event.preventDefault();
    var pathname = window.location.pathname;
    $('body').html('&lt;iframe id="wrapper" src="'+ pathname +'" &gt;')
    $('iframe').load(function (){
           //this is where the magic outght to happen 
    });
}
</code></pre>

<p>When the wrap is run, i want to start manipulating the contents of the iframe. For the structure of the app, I would like need to do this from ouside of the wrap-function or with parameters that I pass in to the wrap function. I do this with a series of functions that execute animations, play sounds etc. (Stuff that takes time and should also be executed sequentially). This Is what i Would Ideally like it to look like.</p>

<pre><code>wrap();
highlight('#one');
highlight('#two');
</code></pre>
