【问题标题】:xulrunner calling external javascriptxulrunner 调用外部 javascript
【发布时间】:2012-08-27 12:16:14
【问题描述】:

我正在尝试使用 XULRunner 制作离线应用程序。我正在尝试将JSTree 集成为树视图。它似乎没有调用外部js。该代码在普通的 html 文件中正常工作。任何想法为什么它不在 XULRunner 中?我的 xul 文件的代码是这样的:

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
  id="findfile-window"
  title="Find Files"
  width="800"
  height="500"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!--General Use jQuery
<script src="jquery/jquery-1.8.0.js"/>-->

<!--jstree plugin-->
<script src="jstree/_lib/jquery.js"/>
<script src="jstree/jquery.jstree.js"/>
<script>
        $(document).ready(function(){
            $("#bibletree").jstree({
                "plugins" : [ "themes", "html_data" ],
                "themes" : {
                    "icons" : false,
                    "dots" : false
                }
            });
        });
 </script>


        <html:div id="bibletree">
        <html:ul id="lvl">
            <html:li><html:a href="#">Genesis</html:a>
                <html:ul>
                    <html:li><html:a href="#">01</html:a></html:li>
                    <html:li><html:a href="#">02</html:a></html:li>
                    <html:li><html:a href="#">03</html:a></html:li>
                    <html:li><html:a href="#">04</html:a></html:li>
                    <html:li><html:a href="#">05</html:a></html:li>
                    <html:li><html:a href="#">06</html:a></html:li>
                                    ...
</window>

【问题讨论】:

  • 它可能不起作用,因为 XUL 使用了flexible box layout。或者它可能正在调用document.createElement() 而不是document.createElementNS()。无论哪种方式,使用 XUL 树可能更有意义,而不是尝试使不适合 XUL 的脚本工作。你可以将该脚本加载到 XHTML 文档中。
  • 所以我认为 xulrunner 的整个想法是使用 javascript、html 和 css 来制作在线/离线应用程序是错误的吗?
  • 比这更微妙,你确实使用 js、html 和 css。只是有时 xulrunner 的情况有所不同。
  • 您是否也尝试过仅包含一个自定义 JavaScript 文件,该文件只会发出警报(“嗨,我已加载”),这样您就可以凭经验知道该文件是否已加载。
  • @preahkumpii:您可以使用 XULRunner 创建离线应用程序 - 但如果您想使用 HTML,那么您应该添加一个框架并将 HTML 文档加载到其中。将 XUL 与 HTML 混合使用有其怪癖。

标签: javascript html xul xulrunner


【解决方案1】:

是的,

文档对象在 XUl 中没有 onload 或 ready 事件,您必须在 'window' 对象中侦听 'load' 或使用 'onload'。

链接: https://developer.mozilla.org/en-US/docs/XUL/Events#Window_events

【讨论】:

    猜你喜欢
    • 2012-04-13
    • 2018-04-22
    • 2013-01-12
    • 1970-01-01
    • 2014-10-01
    • 2013-01-22
    • 1970-01-01
    • 1970-01-01
    • 2015-03-02
    相关资源
    最近更新 更多