0

I have an iframe element that, when I click on a picture, it will open below it.

My problem is that, when I open the popup (iframe) and resize the page, the iframe is not keeping the position below the picture.

iframeLoginControl.style.position = 'absolute';
iframeLoginControl.style.left = parseInt(imgBtnPos.left) - 12 + "px";
iframeLoginControl.style.top = parseInt(imgBtnPos.top) + parseInt(imgButtonObj.height) - 1 + "px";

I think my problem is with imgBtnPos.left that not gets refreshed when I resize the page.

4

2 回答 2

0

您应该使用更多代码来详细说明这一点。首先,您必须重新计算窗口元素的“onresize”事件中的位置。如果您已经这样做了,请检查代码中的“imgBtnPos”变量:它是什么?它是对您的 DOM 元素的引用吗?如果是这样,您忘记在 '.left' 和 '.top' 之前放置 '.style' 关键字

于 2012-11-15T12:01:19.113 回答
0

这里的问题是您将绝对定位在页面的自然iframe之外。您的坐标在您设置它的那一刻被引用到相对父级的左上角。

您必须将iframe相对位置定位到image- 这样它就会随着页面的流动而移动。

您还没有提供将 iframe 附加到文档的方式,但是如果您将其附加到内联,并且您没有绝对定位它,它应该可以正常工作。

于 2012-11-15T12:01:29.940 回答