【发布时间】:2008-12-29 08:12:59
【问题描述】:
我有一个包含 3 个框架的基于框架的网页。顶线、左侧导航和右下角内容框架。
现在,我想在用户右键单击内容框架时显示一个弹出菜单。因为 div-container 不能跳出框架,所以我的想法是,将整个框架页面放入一个新的 iframe 中。在那个页面中,我可以有第二个 iframe,这是我的弹出菜单。
所以现在,我有这个布局:
<html> (start-page)
<iframe (real content)
<frameset
top-frame
navigation-frame
content-frame
>
>
<iframe> (my popup-menu, positioned absolutelly and hidden by default)
</html>
在我的内容框架中,我将“onmouseover”事件分配给正文标签。此事件应在当前鼠标位置打开弹出 iframe。这正是我的问题:如何让鼠标坐标相对于顶级网站(我草稿中的起始页)?
目前我有这个 mouseDown 功能(现在只在 IE 中工作 - 但让它在 FF & Co 中工作不应该是问题......)
function mouseDown(e)
{
if (window.event.button === 2 || window.event.which === 3)
{
top.popupFrame.style.left = event.screenX + "px";
top.popupFrame.style.top = event.screenY + "px";
top.popupFrame.style.display = "";
return false;
}
}
如您所见,“event.screenX”和“screenY” - 变量不是我可以使用的变量,因为它们与主页无关。
有什么想法吗?
【问题讨论】:
-
帧中帧不是最佳解决方案。我建议您删除带有框架集定义的页面并将其替换为带有 iframe 的页面。这样一来,您只能获得一级深度的帧。
-
另外,由于您只在 mouseDown 中使用 window.event,它只能在 IE 和 Opera 中使用。
-
正如我在问题中所写,我已经知道“window.even” - 问题 - 所以这只是一个测试代码,最终什么都没有......
标签: javascript popup frame mouse-position