我的HTML中有以下节点结构:
<div id="widget1" class="dojoxFloatingPane dijitContentPane dojoxFloatingPaneFg" title="" role="group" style="position: absolute; top: 82px; left: 231px; width: 984px; height: 276px; z-index: 102;" widgetid="widget1">
<div class="dojoxFloatingPaneTitle" dojoattachpoint="focusNode" role="button" tabindex="0">
<div class="dojoxFloatingPaneCanvas" dojoattachpoint="canvas" style="left: 0px; top: 0px; width: 984px; height: 249px;">
<iframe class="dijitBackgroundIframe" src="javascript:""" role="presentation" style="opacity: 0.1; width: 100%; height: 100%;" tabindex="-1">
我正在尝试使用Dojo设置此FloatingPane的大小,并具有以下代码。首先,我读取节点,widget1节点,然后查找dojoxFloatingPaneTitle类并将这些节点存储在变量中。然后我读了cookie,它成功地在paneNode上设置了样式。
var paneNode = dom.byId("widget1");
var canvasNode = query(".dojoxFloatingPaneCanvas", paneNode);
function(){
var wid1saved = dojo.fromJson(cookie("widget1"));
domStyle.set(paneNode, {
left: wid1saved.x + "pt",
top: wid1saved.y + "pt",
width: wid1saved.w + "px",
height: wid1saved.h + "px",
position: "absolute"
});
domStyle.set(canvasNode, {
width: wid1saved.w + "px",
height: wid1saved.h + "px",
backgroundColor: "black"
});
}
它确实设置了外部节点(paneNode)的大小,但是canvas(canvasNode)中的画布没有改变。在调试器中,我可以看到查询确实找到了正确的节点。 为什么没有设置canvasNode样式的想法?
非常感谢
答案 0 :(得分:2)
dojo.query通常返回找到的对象数组。
你试过了吗?
var canvasNode = query(".dojoxFloatingPaneCanvas", paneNode)[0];