2

In a xulrunner app, I seem to be unable to set the title from JavaScript. I have tried setting in these two ways:

<?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 shows that the title attribute does get updated, but it does not show up on screen.

pc1oad1etter
  • 8,549
  • 10
  • 49
  • 64

2 Answers2

4
[CDATA[
function entry_onLoad()
{
   document.title = "MyTitle"
}

addEventListener("load", entry_onLoad, false)

]]>

This works

stealthyninja
  • 10,343
  • 11
  • 51
  • 59
Mikhail
  • 41
  • 2
0

It appears that after the page loads one cannot change the window. If there is a way, I'd be interested to know it.. but this does work:

<?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>
pc1oad1etter
  • 8,549
  • 10
  • 49
  • 64