I'd like xul window to load pages in current window instead of new window 在当前窗口而不是新窗口中加载页面
I have 3 files in the same directory,
main.xul
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<browser type="content" src="page_a.html" width="100%" height="100%" />
</window>
page_a.html
<html>
<body>
<a href="page_b.html"
target="_blank" >I'm page a, click to navigate to page_b.html</a>
</body>
</html>
page_b.html
<html>
<body>
<a href="page_a.html"
target="_blank" >I'm page b, click to navigate to page_a.html</a>
</body>
</html>
When i run the xul using xulrunner and click the link, the whole
window disappear
but i want to load the target page "page_b.html" in current window,
I tried both <browser>
and <iframe>
approach, neither of them work.
the window disappears as long as it tries to open a new window to load target webpage.
If I replace target="_blank"
to target="_self"
, the code runs successfully.
but the matter is what if i load a remote page that contains target="_blank"
and is not written by me, for example http://www.google.com/ ?
So how to load pages in current window despite the attribute of <a>
element? 在当前窗口中加载页面?
Thanks.
You'll need to implement nsIBrowserDOMWindow
and set it to the window .
In your openURI
implementation, you'd then call .loadURIWithFlags
on your <browser>
(compare with the linked implementation from browser.js
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.