如何在不同的帧上移动Div?

时间:2011-07-01 07:26:24

标签: javascript html jsp

我的页面有3帧。我在第1帧有一个div,我希望它显示在第2帧所在的页面中心。我该怎么做呢?我无法将该代码放在第二帧中。

2 个答案:

答案 0 :(得分:0)

使用'position:absolute'。

更多信息 http://www.w3schools.com/css/css_positioning.asp

另外,不要使用框架 - 不是一个好主意!使用div的+ ajax。

答案 1 :(得分:0)

Divs不会交叉帧,因此您无法显示跨越帧的div

如果要在另一个框架中显示div并且所有页面都来自同一服务器,只需使用top.otherFrame.document访问该框架中的页面

var div = top.otherFrame.document.createElement('div');
div.innerHTML="Hello";
div.style.position="absolute"; // postioned from 0,0 of the FRAME top left corner
div.style.top="200px";
div.style.left="100px";

top.otherFrame.document.body.appenChild(div);