问题
I get the utils
of the window like this:
var utils = Services.wm.getMostRecentWindow('navigator:browser').
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils);
then running this code says its not a function:
Services.prompt.alert(null, 'is modal?', utils.isInModalState())
//Exception: utils.isInModalState is not a function
even though it says in the documentation it is.
I am not able to run this code either:
utils.enterModalState()
It runs without error but the window does not enter or leave modal state.
回答1:
The .isInModalState
property is actually tagged [noscript], so it is not available in Javascript, only C++.
.enterModalState()
doesn't do what you think it does. It does not make a window UI-modal (like an alert dialog). It just essentially suspends scripts and event processing in the window.
来源:https://stackoverflow.com/questions/24684696/nsidomwindowutils-isinmodalstate-not-working