我正在更新旧代码,而这部分无效:
IFrameElement iframe = query('#myframe iframe');
Window iframeW = iframe.contentWindow;// cast error
var myframeDoc = iframeW.document;
我将
Window
更改为“WindowBase”:IFrameElement iframe = query('#myframe iframe');
WindowBase iframeW = iframe.contentWindow;
var myframeDoc = iframeW.document;
但是
document
不是WindowBase
的成员。我想访问它来像这样查询:
myframeDoc.query("#myId");
使用javascript,该解决方案适用:
var myframeDoc = document.querySelector('#myframe iframe').contentWindow.document;
最佳答案
iFrame和Windows的API略有不同,因此您必须使用WindowBase
而不是Window
。
您可以在API文档中看到IFrameElement.contentWindow
的类型是WindowBase
,并且还应该在编辑器的弹出文档中看到它。
关于dart - 该文档不是WindowBase的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15444109/