I'm trying to get JQuery Mobile working inside an iframe. I initiated an onload function to load the external scripts inside the head section of the iframe. I also included a button to see if the scripts loaded.
For some reason the ajax loader just keeps spinning and spinning as if the script is hung up on something.
Here's jsFiddle: http://jsfiddle.net/pz4uH/9/
Something wrong here...Also, How do i declare a !DOCTYPE inside an iframe?
HTML
<div id='main'>
<div id='rightP'>
<div id='theframe' class='phn'>
<iframe id='themagic'>
</iframe>
</div>
</div>
</div>
Javascript
function doThis() {
alert('onload works');
var myIframe = document.getElementById("themagic");
var link1 = myIframe.contentWindow.document.createElement('link');
link1.type = 'text/css';
link1.href = 'http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css';
link1.rel = 'stylesheet';
myIframe.contentWindow.document.head.appendChild(link1);
var scr1 = myIframe.contentWindow.document.createElement("script");
scr1.type = "text/javascript";
scr1.src = 'http://code.jquery.com/jquery-1.9.1.js';
myIframe.contentWindow.document.head.appendChild(scr1);
var scr2 = myIframe.contentWindow.document.createElement("script");
scr2.type = "text/javascript";
scr2.src = 'http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.js';
myIframe.contentWindow.document.head.appendChild(scr2);
var btn = myIframe.contentWindow.document.createElement('button');
btn.innerHTML = 'Click Me';
myIframe.contentWindow.document.body.appendChild(btn);
}
window.onload = doThis();
//