Unfortunately, it only works once. If I changed
the src of the frame, the frameset won't trigger
a second time. Is there anything I can do to
get that affect? ie. an onload handler for a frame
no matter how many times the src document for
that frame has changed.
Thanks.
--
Martin Honnen
http://javascript.faqts.com/
http://home.t-online.de/home/martin.honnen/jsgoddies.html
Doesn't seem to work on NN 4.7:
loading http://www.faqts.com...
loading http://javascript.faqts.com...
I gather it should be:
loading http://www.faqts.com...
loaded ____ in ____
loading http://javascript.faqts.com...
loaded ____ in ____
Doesn't work in NN6 either - but it has an extra priviledge
not granted exception
John
There is currently no XML parsing API in Javascript
(that I am aware of)
I planned to load all requests through a hidden frame.
(At the moment, I'm show the frame for debugging
purposes). In order for it to work properly, the
script needs to know when the frame has loaded
the XML document. The requirement here is
that there be absolutely no scripts in the loading
XML document. Those documents contain pure
XML data. Scripting must all be done externally
in some other frame.
Hence the need for some sort of onload event for
the XML frame and it must work more than once.
Trouble is I haven't been able to detect the onload
event of a frame despite having continually tried for
a whole day.
Because the frameset onload event only occurs
once, it is inadequate for this application.
Thanks for the help so far.
John
<HTML>
<HEAD>
<STYLE>
</STYLE>
<SCRIPT>
function FileLoader (url, onload) {
this.id = FileLoader.cnt;
FileLoader.elements[FileLoader.cnt++] = this;
this.url = url;
this.onload = onload;
this.createIFRAME();
setTimeout('FileLoader.elements[' + this.id + '].loadDocument()', 20);
}
function FileLoader_createIFRAME () {
this.frameName = 'FileLoader' + this.id;
if (document.all) {
var html = '';
html += '<IFRAME ID="' + this.frameName + '"';
html += ' NAME="' + this.frameName + '"';
html += ' STYLE="visibility: visible;"';
html += ' SRC="about:blank">';
html += '<\/IFRAME>';
document.body.insertAdjacentHTML('beforeEnd', html);
}
else if (document.getElementById) {
var ifr = document.createElement('IFRAME');
ifr.id = ifr.name = this.frameName;
ifr.style.visibility = 'visible'; // just for testing
ifr.width = 300; ifr.height = 100;
ifr.src = 'about:blank';
document.body.appendChild(ifr);
}
}
FileLoader.prototype.createIFRAME = FileLoader_createIFRAME;
function FileLoader_loadDocument (url) {
if (url)
this.url = url;
this.loaded = false;
this.document = null;
var ifrWin =
document.all ? document.frames[this.frameName] :
window.frames[this.frameName];
var html = '';
html += '<HTML>';
html += '<BODY ONLOAD="';
html += 'alert(event.type);'; // just for testing
html += 'var fl = top.FileLoader.elements[' + this.id + '];';
html += 'fl.loaded = true;';
html += 'fl.document = window.frames[0].document;';
html += 'fl.onload(fl.document);';
html += '"';
html += '>';
html += '<IFRAME SRC="' + this.url + '">';
html += '<\/IFRAME>';
html += '<\/BODY>';
html += '<\/HTML>';
ifrWin.document.open();
ifrWin.document.write(html);
ifrWin.document.close();
}
FileLoader.prototype.loadDocument = FileLoader_loadDocument;
FileLoader.cnt = 0;
FileLoader.elements = new Array();
</SCRIPT>
<SCRIPT>
var fl;
function loadHandler (document) {
if (document.all)
alert(document.all.length)
else
alert(document.getElementsByTagName('*').length);
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="formName">
<A HREF="javascript: void 0"
ONCLICK="fl = new FileLoader('whatelse.html', loadHandler); return
false;"
>
new FileLoader
</A>
|
<A HREF="javascript: void 0"
ONCLICK="fl.loadDocument('whatever.html'); return false;"
>
load whatever.html
</A>
<BR>
</BODY>
</HTML>
--