我有以下javascript:
$('#ge-display').click(function (event) {
window.open('/googleearth/ge-display.php','','scrollbars=yes,menubar=no,height=650,width=1000,resizable=yes,toolbar=yes,location=no,status=no');
event.stopPropagation();
return false;
});
Run Code Online (Sandbox Code Playgroud)
ID为'ge-display'的元素是标准链接:
<a href="/googleearth/ge-display.php" id="ge-display" target="_blank">Load Google Earth Plugin (in a new window)</a>
Run Code Online (Sandbox Code Playgroud)
问题是 - 当我拿出'return false;'时 来自click事件处理程序的行,javascript弹出窗口打开,然后另一个浏览器窗口打开 - 我以为stopPropagation()会阻止链接自己的点击处理程序?
我也尝试过stopImmediatePropagation() - 但我仍然需要返回false来停止链接的默认行为.
SLa*_*aks 16
调用event.stopPropagation()将阻止其他Javascript事件处理程序处理该事件.它不会阻止浏览器的默认操作.
你需要打电话event.preventDefault().
| 归档时间: |
|
| 查看次数: |
6802 次 |
| 最近记录: |