For comparison's sake here is a simple example of my iframe method. You can keep loading the same scripts over and over into successive iframes and it still works.
Code:
<html>
<head>
<script type="text/javascript">
function HTTPReq() {
var theAJAX;
if(window.XMLHttpRequest) {
theAJAX = new XMLHttpRequest();
if(theAJAX.overrideMimeType) {
theAJAX.overrideMimeType('text/xml');
}
} else if(window.ActiveXObject) {
try {
theAJAX = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e){
try {
theAJAX = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
theAJAX = false;
}
}
}
if(!theAJAX){
alert('Giving up :( Cannot create an XMLHTTP instance');
}
return theAJAX;
}
function doAjaxPost(paramList,url,onsuccess,onfail) {
var ajax = HTTPReq();
if (!ajax) return;
var paramArr = [];
for (var item in paramList) {
// don't handle arrays, objects, functions, etc
if (typeof paramList[item] == "string" || typeof paramList[item] == "number") {
paramArr.push(encodeURIComponent(item) + "=" + encodeURIComponent(paramList[item]));
}
}
var params = paramArr.join("&");
ajax.open("POST", url, true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
ajax.onreadystatechange = function() {
if (ajax.readyState == 4) {
if (ajax.status == 200 || ajax.status == 0) {
onsuccess(ajax.responseText);
} else {
onfail(ajax.status);
}
}
}
ajax.send(params);
}
function loadPage() {
doAjaxPost({},"test.html",
function (ajaxText) {
window.frames["stuffGoesHere"].document.write(ajaxText);
},
function (statusCode) {
alert("error loading page, status was " + statusCode);
}
);
}
</script>
</head>
<body>
<h2>Iframe test</h2>
<button onclick="loadPage();">Load a page</button><br/>
<iframe name="stuffGoesHere"></iframe>
<h2>end of iframe test</h2>
</body>
</html>
Bookmarks