我得到窗口的 utils
是这样的:
var utils = Services.wm.getMostRecentWindow('navigator:browser').
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
然后运行这段代码说它不是一个函数:
Services.prompt.alert(null, 'is modal?', utils.isInModalState())
//Exception: utils.isInModalState is not a function
即使它说 in the documentation是的。
我也无法运行这段代码:
utils.enterModalState()
它运行没有错误,但窗口没有进入或离开模式状态。
最佳答案
.isInModalState
属性实际上是 tagged [noscript]
,因此它在 Javascript 中不可用,仅在 C++ 中可用。
.enterModalState()
并不像您认为的那样。它不会使窗口 UI 模式(如警报对话框)。它只是在本质上暂停了窗口中的脚本和事件处理。
关于javascript - nsIDOMWindowUtils.isInModalState() 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24684696/