chrome中的帧问题

时间:2012-12-19 08:37:31

标签: javascript facebook-javascript-sdk

我正面临着使用此特定代码抛出错误的帧的问题:

window.parent.frames["searchoutput"].document.open("text/html");

错误:未捕获的TypeError:无法调用未定义的方法'open'

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

var frame = window.parent.frames["searchoutput"];
var frameDocument = (frame.contentWindow.document || frame.contentDocument);
frameDocument.open("text/html");

或更全面的版本来检查如何获取文档:

var doc;
if (iframe.document)
    iframe.doc = iframe.document;
else if (iframe.contentDocument)
    iframe.doc = iframe.contentDocument;
else if (iframe.contentWindow)
    iframe.doc = iframe.contentWindow.document;