从dojo内容窗格中的html加载特定的id内容

loading specific id content from html in dojo content pane

本文关键字:加载 html 内容 id dojo      更新时间:2023-09-26

我正试图在单击树节点时在Dojo内容窗格中加载特定的html id内容。我有一个很长的html,里面有几个标题。我正试图在点击树节点时从这个html加载内容。我可以加载html,但我不能将具有特定id的内容放在内容窗格的顶部。

假设我的html是abc.html,它有几个id,比如id1id2。。。若我用参数abc.html在IE中打开这个html,页面就会被加载,第一行在顶部。现在,如果我用参数abc.html#id9打开它html的这个特定部分被加载到IE窗口的顶部。

我试图在dojo内容窗格中实现同样的效果——这里的内容是在点击树节点时加载到dojo内容窗格中的,目标是在内容窗格中加载与该树节点相关联的特定#id,而不是加载html顶部。

它从不在内容窗格顶部加载特定的id内容。它总是像参数是abc.html一样加载。我看不出abc.html#id9 有任何影响

下面是我如何创建内容窗格并在点击树节点上加载内容的代码片段。

....
   var CenterPane = new  ContentPane({//content pane at center for loading urls of selected designs
     content:"Click to get the details about node",
     region:"center"});
   bordContainer.addChild(CenterPane);//add content pane to the border container
....
....
var fileTree = new Tree ({
            model: treeModel,
            showRoot: false,
            openOnClick:true,
            autoExpand:false,
            _createTreeNode: function (args)
              {   
                return new MyTreeNode(args);
              },
             onClick: function(args) {
CenterPane.set("href", vHtmlPath); }
....

vHtmlPath被动态地设置为abc.html#id9abc.html#id1。。。。

ContentPane不会加载到iframe中。如果你想移动,你必须更改当前页面的url。例如

CenterPane.set("href", vHtmlPath).then(function() {
    document.location.href = "#id9"
}