Tabcontainer 的行为因浏览器而异

发布于 2024-08-13 00:16:58 字数 1216 浏览 2 评论 0原文

以下代码适用于 IE8、Safari 4.0.2 - 但在 Firefox 3.5.5 上生成空页面。有什么想法吗?

<html>
 <head>
  <link rel="stylesheet" type="text/css" href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/themes/tundra/tundra.css">
</head>
<body class="tundra">
 <div style="width: 350px; height: 300px">
  <div id="tc1-prog">
 </div>
</div>
</body>

 <script type="text/javascript" src="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojo/dojo.js"
  djConfig="parseOnLoad: true">;
  </script>
  <script type="text/javascript">
    dojo.require("dijit.layout.TabContainer");
    dojo.require("dijit.layout.ContentPane");

 dojo.addOnLoad(function() {
        var tc = new dijit.layout.TabContainer({
                style: "height: 100%; width:100%;"
        },
        "tc1-prog");

        var cp1 = new dijit.layout.ContentPane({
        title: "Food",
        content: "We offer amazing food"
    });
    tc.addChild(cp1);

    var cp2 = new dijit.layout.ContentPane({
        title: "Drinks",
        content: "We are known for our drinks."
    });
    tc.addChild(cp2);

    tc.startup();
});
</script>
</html>

The following code works on IE8, Safari 4.0.2 - but generates an empty page on Firefox 3.5.5. Any idea ?

<html>
 <head>
  <link rel="stylesheet" type="text/css" href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/themes/tundra/tundra.css">
</head>
<body class="tundra">
 <div style="width: 350px; height: 300px">
  <div id="tc1-prog">
 </div>
</div>
</body>

 <script type="text/javascript" src="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojo/dojo.js"
  djConfig="parseOnLoad: true">;
  </script>
  <script type="text/javascript">
    dojo.require("dijit.layout.TabContainer");
    dojo.require("dijit.layout.ContentPane");

 dojo.addOnLoad(function() {
        var tc = new dijit.layout.TabContainer({
                style: "height: 100%; width:100%;"
        },
        "tc1-prog");

        var cp1 = new dijit.layout.ContentPane({
        title: "Food",
        content: "We offer amazing food"
    });
    tc.addChild(cp1);

    var cp2 = new dijit.layout.ContentPane({
        title: "Drinks",
        content: "We are known for our drinks."
    });
    tc.addChild(cp2);

    tc.startup();
});
</script>
</html>

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

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

发布评论

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

评论(2

无名指的心愿 2024-08-20 00:16:58

可能是跨域问题。每晚构建已发布用于测试,但要在本地实际使用它,您必须下载 tarball。否则,会使用 xhr+eval 进行引用来加载各个模块,这会破坏浏览器的域安全模型。

您的另一个选择是使用 Dojo 的“跨域”构建,这几乎正是您想要做的,而且部署起来超级简单——只需用脚本标签指向它即可。这就是 Google CDN 上提供的内容。

Likely a cross-domain problem. The nightly build is posted for testing, but to actually use it locally, you must download the tarball. Otherwise, references are made to load individual modules using xhr+eval which break the browser's domain security model.

Your other choice is to use a "cross domain" build of Dojo, which is pretty much what you wanted to do and super simple to deploy -- just point at it with the script tag and off you go. That's what's available on the Google CDN.

淡淡的优雅 2024-08-20 00:16:58

您可能想将 script 标签放在 body 标签内。为了使其成为有效的 HTML,它需要位于 body 或 head 标记中。无效的文档肯定会导致它在浏览器之间运行不一致。

更新:此外,您可能想尝试使用生产构建而不是夜间构建。我将网址更改为使用 http://ajax。 googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js 它在 FF 中对我来说工作得很好。它因夜间构建而被打破。

来自 HTML 4.01 规范

HTML 4 文档由三部分组成:

包含 HTML 版本信息的行,
声明性标头部分(由 HEAD 元素分隔),
正文,其中包含文档的实际内容。主体可以由BODY元素或FRAMESET元素来实现。

<html>
<head>
  <link ... />
</head>
<body>
   ...
   <script ... >
   </script>
</body>
</html>

You might want to put the script tag inside the body tag. For it to be valid HTML, it needs to be either in a body or head tag. An invalid document could certainly result in it not operating consistently between browsers.

Update: Also, you might want to try using a production build instead of the nightly build. I changed the URL to use http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js and it worked fine for me in FF. It was broken with the nightly build.

From the HTML 4.01 Spec:

An HTML 4 document is composed of three parts:

a line containing HTML version information,
a declarative header section (delimited by the HEAD element),
a body, which contains the document's actual content. The body may be implemented by the BODY element or the FRAMESET element.

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