I am currently working on a website project. The sites are loaded into a <div> by using ajax. Everything was working well until I tried to load a page into a <div> with some sort of javascript code on that page. The javascript didn't run after that site had been loaded into that <div>.
For example This is the <div> tag on the main page:
I tried to load another page into that div:
None of those javascript lines were executive.
Pretty easy. I used DOM method to detach the body part.
And then make an object and
For example This is the <div> tag on the main page:
Code:
<div id="loadPage"> </div>
Code:
<html> <body> <script type="javascript/text"> alert('TEST'); document.write('Doesn't work');</script> </body> </html>
Pretty easy. I used DOM method to detach the body part.
Code:
function makeAjaxObject() { //For older broswsers and IE var xmlObj = false; try { xmlObj = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlObj = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e2) { xmlObj = false; } } //For browers that support XMLHTTP if (!xmlObj && typeof XMLHttpRequest != 'undefined') { xmlObj = new XMLHttpRequest(); } return xmlObj; }
Code:
document.getElementById(pageLoaderDivID).innerHTML = getBody(loadedContent);
Comment