将javascript弹出窗口从onclick更改为onmouseover

时间:2013-04-16 05:10:19

标签: javascript

如何将弹出窗口的以下javascript从“open popup onclick”更改为打开/关闭弹出窗口onmouseover / onmouseout。

<area alt="" coords="127, 22, 20" alt="" href="includes/popup1.htm" onclick="javascript:void window.open('includes/popup1.htm','1366002941508','width=500,height=200,left=350,top=250');return false;" shape="circle" />

1 个答案:

答案 0 :(得分:0)

在打开窗口时存储对弹出窗口的引用,并在.close()处理程序中的窗口上调用mouseout

<area
    onmouseover="popup = open('includes/popup1.htm','1366002941508','width=500,height=200,left=350,top=250');"
    onmouseout="popup && popup.close();"
    coords="127, 22, 20" alt="" href="includes/popup1.htm" shape="circle" />

但是,既然弹出窗口不是由点击触发的,那么你肯定会被弹出窗口阻止程序阻止。考虑在浮动div中显示内容而不是单独的窗口。