Mozilla 重新加载 API 方法不起作用
我尝试使用(JavaXPCOM)重新加载网页:
nsIWebBrowser webBrowser = (nsIWebBrowser) browser
.getWebBrowser();
nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
try {
nsISHistory sessionHistory = webNavigation.getSessionHistory();
if (sessionHistory != null) {
webNavigation = (nsIWebNavigation) sessionHistory.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
}
} catch (XPCOMException e) {
}
webNavigation.reload(nsIWebNavigation.LOAD_FLAGS_NONE);
但重新加载根本没有发生。我尝试使用以下标志强制它,但页面也不会刷新:
nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY|nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE
有人知道这可能是什么原因吗? 谢谢!
I try to reload a Web page using (JavaXPCOM):
nsIWebBrowser webBrowser = (nsIWebBrowser) browser
.getWebBrowser();
nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
try {
nsISHistory sessionHistory = webNavigation.getSessionHistory();
if (sessionHistory != null) {
webNavigation = (nsIWebNavigation) sessionHistory.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
}
} catch (XPCOMException e) {
}
webNavigation.reload(nsIWebNavigation.LOAD_FLAGS_NONE);
But reload doesn't happen at all. I tried force it by using the following flags, but page doesn't refresh as well:
nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY|nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE
Anyone knows what can be the reason for that?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试检查错误控制台是否有语法错误?您似乎正在尝试在 JavaScript 中使用 C++ 类型转换。那是行不通的。假设
browser
是一个
元素,这应该可以工作:或者:
参见 https://developer.mozilla.org/en/XUL/browser 有关
元素的文档。编辑:考虑到这显然是使用 JavaXPCOM,代码似乎是正确的,但整个
try .. catch
块应该被删除。唯一的标志应该是LOAD_FLAGS_BYPASS_CACHE
,以确保您不会获得缓存的响应。Did you try checking Error Console for syntax errors? You seem to be trying to use C++ type casts in JavaScript. That cannot work. Assuming that
browser
is a<browser>
element, this should work:Or:
See https://developer.mozilla.org/en/XUL/browser for documentation on the
<browser>
element.Edit: Given that this is apparently using JavaXPCOM the code seems to be correct with the exception that the entire
try .. catch
block should be removed. The only flag should beLOAD_FLAGS_BYPASS_CACHE
to make sure you don't get a cached response.