如果用户单击将在新窗口中打开的链接,如何显示 javascript 警告?

发布于 2024-08-27 19:28:14 字数 333 浏览 4 评论 0原文

如果用户单击将在新窗口中打开的链接,如何向用户显示这种类型的提醒警告(主要是屏幕阅读器用户需要这个)?

我的措辞可以吗,请建议是否可以更好?我想为在新窗口中打开的网站或文件(例如 PDF、DOC 等)的任何链接显示此消息?

有时用户点击错误,所以我想再次提醒。

我已经在使用 jquery 那么如何使用 jquery 显示这样的警告框?

替代文本 http://shup.com/Shup/308607/warning.gif

How to show this type of reminder warning to user (mainly i need this for screen reader user), if user click on link which will open in new window?

Is my wording ok, please suggest if it can be better ? I want to show this message for any link of website or file like PDF, DOC etc. which is opening in new window?

Sometime user clicks mistakenly so i want to give another reminder.

I'm already using jquery so how to show like this warning box using jquery?

alt text http://shup.com/Shup/308607/warning.gif

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

淡淡の花香 2024-09-03 19:28:14

在窗口上使用 onbeforeunload 事件。检查如何防止网页在 JavaScript 中导航?< /a>

window.onbeforeunload = function() {
  return "Are you sure you want to navigate away?";
}

use the onbeforeunload event on window. check How do you prevent a webpage from navigating away in JavaScript?

window.onbeforeunload = function() {
  return "Are you sure you want to navigate away?";
}
冷︶言冷语的世界 2024-09-03 19:28:14

如果您的意思是 target 属性设置为 _blank 的链接,您可以执行以下操作:

$("a[target='_blank']").click(
    function(){
        return confirm("Are you sure?");
    }
);

If what you mean are links that have the target property set to _blank, you may do the following:

$("a[target='_blank']").click(
    function(){
        return confirm("Are you sure?");
    }
);
放血 2024-09-03 19:28:14

在新窗口中?我不知道我是否理解您真正想要的,但我相信您捕获的屏幕截图是 unload 事件触发的通知 - 如果您使用 jQuery,请检查 jQuery 的 .unload()

In new window? I don’t know if I understood what you really want, but I believe the screenshot you captured is a notification triggered on unload event—if you use jQuery, check jQuery’s .unload().

溺渁∝ 2024-09-03 19:28:14

向目标属性为 _blank 的所有 a 标签添加点击事件。单击事件将显示确认对话框。

Add a click event to all a tags that have a target attribute that is _blank. The click event will display the confirmation dialog.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文