我只需要一个简单的对话框,通过点击第三方链接让用户知道他们要离开网站。除了Safari和Chrome之外,这在jst中运行良好。难道我做错了什么?以下是我正在使用的链接示例:
<a href="http://www.website.net" target="_blank" onClick="return confirm('You are leaving the example website!')">Sample Link</a>
答案 0 :(得分:0)
试试这个:
<强> HTML 强>
<body onbeforeunload="return confirmLeave(event);">
JS
function confirmLeave(e)
{
return "You are leaving the example website!";
}
答案 1 :(得分:0)
您是否可以禁用弹出式窗口? 使用OS X 10.10.5,这些代码段在Chrome和Safari中完美运行 在这里,您有一个用于在chrome
中启用它们的链接答案 2 :(得分:0)
在Safari中遇到此问题。我认为您需要将onclick
添加到实际元素,例如<div>
,而不是仅添加<a>
标记。
替换它:
<a href="http://www.website.net" target="_blank" onClick="return confirm('You are leaving the example website!')">Sample Link</a>
用这个:
<a href="http://www.website.net" target="_blank">
<div onclick="return confirm('You are leaving the example website!')">Sample Link</div>
</a>