<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
function LoadHttp(myName, callback, uri){
with (this)
{
if(!document.readyState)
document.readyState = "completed";
this.myName = myName;
this.callback = callback; // 'iframe' is our fallback: a reference to a dynamically created IFRAME buffer.
this.iframe = null;
window._ifr_buf_count |= 0;
this.iframeID = 'iframebuffer' + window._ifr_buf_count++;
// A loading flag, set to the requested URI when loading.
this.loadingURI = ''; // In MSIE or browsers with no XMLHttpRequest support: fallback to IFRAMEs buffers.
// I'm using IFRAMEs in MSIE due to XMLHTTP not parsing text/html to a DOM.
// Also used in IE5/Mac, Opera 7.x, Safari <1.2, some Konqueror versions, etc.
if (document.createElement && document.documentElement &&
(window.opera || navigator.userAgent.indexOf('MSIE 5.0') == -1))
{
var ifr = document.createElement('iframe');
ifr.setAttribute('id', iframeID);
ifr.setAttribute('name', iframeID);
// Hide with visibility instead of display to fix Safari bug.
ifr.style.visibility = 'hidden';
ifr.style.position = 'absolute';
ifr.style.width = ifr.style.height = ifr.borderWidth = '0px';
iframe = document.getElementsByTagName('body')[0].appendChild(ifr);
}
else if (document.body && document.body.insertAdjacentHTML)
{
// IE5.0 doesn't like createElement'd frames (won't script them) and IE4 just plain
// doesn't support it. Luckily, this will fix them both:
document.body.insertAdjacentHTML('beforeEnd', '<iframe name="' + iframeID +
'" id="' + iframeID + '" style="display: none"></iframe>');
}
// This helps most IE versions regardless of the creation method:
if (window.frames && window.frames[iframeID]) iframe = window.frames[iframeID];
iframe.name = iframeID;
}
this.load(uri);
// TODO: Put in further DOM3 LSParser support as a transport layer...?
return this;
}; LoadHttp.prototype.iframeSend = function(uri, formRef)
{
with (this)
{
// Routes a request through our hidden IFRAME. Pass a URI, and optionally a
// reference to a submitting form. Requires proprietary 'readyState' property. if (!document.readyState)
return false; // Opera fix: force the frame to render before setting it as a target.
if (document.getElementById)
var o = document.getElementById(iframeID).offsetWidth; // Either route the form submission to the IFRAME (easy!)...
if (formRef)
formRef.setAttribute('target', iframeID);
else
{
// ...or load the provided URI in the IFRAME, checking for browser bugs:
// 1) Safari only works well using 'document.location'.
// 2) Opera needs the 'src' explicitly set!
// 3) Konqueror 3.1 seems to think ifrDoc's location = window.location, so watch that too.
var ifrDoc = iframe.contentDocument || iframe.document; if (!window.opera && ifrDoc.location && ifrDoc.location.href != location.href)
ifrDoc.location.replace(uri);
else
iframe.src = uri;
} // Either way, set the loading flag and start the readyState checking loop.
// Opera likes a longer initial timeout with multiple frames running...
loadingURI = uri; setTimeout(myName + '.iframeCheck()', (window.opera ? 250 : 100));
return true;
}
}; LoadHttp.prototype.iframeCheck = function()
{
with (this)
{
// Called after a timeout, periodically calls itself until the load is complete.
// Get a reference to the loaded document, using either W3 contentDocument or IE's DOM.
doc = iframe.contentDocument || iframe.document;
// Check the IFRAME's .readyState property and callback() if load complete.
// IE4 only seems to advance to 'interactive' so let it proceed from there.
var il = iframe.location, dr = !dr || doc.readyState;
if ((il && il.href ? il.href.match(loadingURI) : 1) &&
(dr == 'complete' || (!document.getElementById && dr == 'interactive')
|| doc.documentElement.innerHTML != "<head></head><body></body>"))
{
if (callback)
callback((doc.documentElement || doc), loadingURI);
loadingURI = '';
}
else
{
alert(1);
setTimeout(myName + '.iframeCheck()', 50);
}
}
}; // *** PUBLIC METHODS ***
LoadHttp.prototype.load = function(uri)
{
with (this)
{
// Call with a URI to load a plain text document. if (!uri || !iframe)
return false;
// Route the GET through an available transport layer.
if (iframe)
return iframeSend(uri, null);
else
return false;
}
};
//-->
</SCRIPT> </HEAD>
<BODY>
<span id="showitem"></span>
</BODY>
<SCRIPT LANGUAGE=javascript>
<!--
function onloadshowitem(content, uri)
{
// alert(content.innerHTML);
showitem.innerHTML = content.innerHTML;
}
var lhp = new LoadHttp("lhp", onloadshowitem,"hello.htm");
//-->
</SCRIPT>
</HTML>