在xulrunner应用中,我似乎无法从JavaScript设置标题。我试过这两种方式设置:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="mywindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="go();">
<!-- your code here -->
<script type="application/x-javascript">
<![CDATA[
function go(){
document.getElementById("mywindow").title="blar";
document.getElementById("mywindow").setAttribute("title","blar");
}
]]>
</script>
</window>
DOM Inspector显示标题属性 已更新,但不显示在屏幕上。
答案 0 :(得分:4)
[CDATA[
function entry_onLoad()
{
document.title = "MyTitle"
}
addEventListener("load", entry_onLoad, false)
]]>
这有效
答案 1 :(得分:0)
看来,页面加载后无法更改窗口。如果有办法,我有兴趣知道它......但这确实有效:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="mywindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" >
<script type="application/x-javascript">
<![CDATA[
function go(){
document.getElementById("mywindow").title="blar";
}
go();
]]>
</script>
</window>