changing the content of browser in XULRunner

回眸只為那壹抹淺笑 提交于 2020-01-24 19:51:26

问题


I have an Xulrunner app that loads fullscreen without any controls and loads a html page by default. The only thing it has is browser element and a popup menu visible on right click. In the popup menu there is option to quit. Then there is a menu entry 'theme2'. I want the browser to load another html when theme2 is clicked.

This is my main.xul, thats loaded by default:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="Edusoft" hidechrome="true" sizemode="maximized" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript">
function do()
{
 var browser1 = document.getElementById('browser');
 browser1.loadURI("chrome://myapp/content/theme2/home.html");
}
</script>

<browser id="browser" type="content" src="chrome://myapp/content/theme1/index.html" flex="1" context="clipmenu"/>



<popupset>
  <menupopup id="clipmenu">
       <menuitem label="About Us"/>
    <menuseparator/>
    <menuitem label="Theme2" oncommand="do();"/>
    <menuseparator/>
    <menuitem label="Exit" oncommand="close();"/>
  </menupopup>
</popupset>

</window>

I tried this, but when the page is loaded this way.. the popup menu is nomore in the new page.

window.location.assign()

There is something like loaduri(), but i have no idea on how to use it.


回答1:


Ok I figured it out.

document.getElementById('browser').loadURI('chrome://myapp/content/flash/demo.htm')


来源:https://stackoverflow.com/questions/3381647/changing-the-content-of-browser-in-xulrunner

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!