Dojo TabContainer加载外部站点

时间:2014-01-09 19:12:27

标签: iframe dojo external tabcontainer

学习道场并且可能会忽略某些事情。

让TabContainer工作,但是当单击选项卡时,想要使用不在同一服务器上的外部文件加载TabContainer。就像iframe的工作方式一样。无论如何使用dojo执行此操作?

谢谢!   贝

1 个答案:

答案 0 :(得分:0)

设置ContentPane

的href属性

Fiddle

require([
    "dijit/layout/TabContainer"
    , "dijit/layout/ContentPane"
    , "dojo/domReady!"
], function(
    TabContainer
    , ContentPane
){
    var tc = new TabContainer({
        style: "height: 100%; width: 100%;"
    }, "tc1-prog");

    var cp1 = new ContentPane({
        title: "Greeting"
        , href: "/gh/gist/response.html/8372613/"
    });
    tc.addChild(cp1);
    tc.startup();
});

如果不支持CORS,您可以使用dojo/dom-construct

创建iframe

Fiddle

require([
    "dijit/layout/TabContainer"
    , "dijit/layout/ContentPane"
    , "dojo/dom-construct"
    , "dojo/domReady!"
], function(
    TabContainer
    , ContentPane
    , domConstruct
){
    var tc = new TabContainer({
        style: "height: 100%; width: 100%;"
    }, "tc1-prog");

    var cp1 = new ContentPane({
        title: "CORS"
        , content: domConstruct.create("iframe", { 
            "src": "http://en.wikipedia.org/wiki/Cross-origin_resource_sharing"
            , "style": "border: 0; width: 100%; height: 100%"
        })
    });
    tc.addChild(cp1);
    tc.startup();
});