我有一個基於框架的網頁與3幀。頂線,左側導航和右下側內容框架。在JavaScript中的幀位置
現在,我想在用戶右鍵單擊內容框架時顯示一個彈出式菜單。由於div容器無法離開框架,我的想法是,將整個框架頁面放入一個新的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」 -event。此事件應在當前鼠標位置打開popup-iframe。正是這裏是我的問題:如何獲得鼠標座標相對於頂級網站(我的草稿中的開始頁面)?
目前我(只,現在工作在IE瀏覽器 - 但得到它在FF &工作合作不應該成爲問題...)具有這種鼠標按下功能
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替換頁面。這樣你只能獲得一層深度的幀。 – some 2008-12-29 08:20:56
此外,由於您只在您的mouseDown中使用window.event,因此它只能在IE瀏覽器中運行,也許在Opera中運行。 – some 2008-12-29 08:24:37