如何更改(从 JavaScript)XUL 窗口的标题?

发布于 2024-07-18 07:44:36 字数 659 浏览 6 评论 0原文

在 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 显示标题属性确实已更新,但它显示在屏幕上。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只是偏爱你 2024-07-25 07:44:36
[CDATA[
function entry_onLoad()
{
   document.title = "MyTitle"
}

addEventListener("load", entry_onLoad, false)

]]>

这有效

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

addEventListener("load", entry_onLoad, false)

]]>

This works

半山落雨半山空 2024-07-25 07:44:36

页面加载后似乎无法更改窗口。 如果有办法,我很想知道......但这确实有效:

<?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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文