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

时间:2015-07-02 11:25:32

标签: javascript html dojo

我正在尝试在单击树节点时在Dojo内容窗格中加载特定的html id内容。 我有一个很长的HTML,有几个标题。我试图在点击树节点上从这个html加载内容。我能够加载html,但我无法在内容窗格的顶部带来具有特定ID的内容。

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

我正在尝试在dojo内容窗格中实现相同的效果 - 此处内容在单击树节点上的Dojo ContentPane中加载,目标是与内容窗格中的该树节点关联的特定于加载的#id,而不是加载顶部of 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); }

....

vHtmlPat h动态设置为abc.html#id9abc.html#id1 ....

1 个答案:

答案 0 :(得分:0)

ContentPane不会加载到iframe中。如果要移动,则必须更改当前页面URL。 例如

public static String getMaritalStatus(String custid) {
        String str = "";
        try {
            Connection conn = con.getDbConnection();
            String sql = "select marital_status from customer_table where cust_id = ?";
            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setString(1, custid);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                str = rs.getString(1);
            }
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
        return str;
    }