I am trying to understand the code below. I pretty much get it and have been able to modify it a bit. But I want to understand it well and I am stuck at ** oIframe.contentDocument ** . I sort of 开发者_Python百科know what it does, but I have not been able to find any documentation on it.
thank you
function command() {
if (!testEl) {
var oDoc = iframe.contentWindow || oIframe.contentDocument;
if (oDoc.document) {
oDoc = oDoc.document;
}
testEl = oDoc.getElementById('testElement');
}
var cmd = this.id;
var bool = false;
var value = this.getAttribute('cmdValue') || null;
if (value == 'promptUser')
value = prompt(this.getAttribute('promptText'));
var returnValue = iframe.contentWindow.inBetween(cmd,bool,value);
var writestring = '';
if (returnValue) writestring += 'Return value: ' + returnValue + '\n\n';
writestring += testEl.innerHTML
There is no oIframe
defined in HTML or javascript by default.
Without seeing the rest of the javascript on this page, I would hazard a guess:
oIframe
is a variable defined elsewhere in javascript, probably being set to an IFrame
. This appears to be a naming convention (see oDoc
in your posted code).
精彩评论