如何使用 javascript 显示类似于此处的警报的内容?
如何使用 javascript 显示类似于此处的警报的内容?
How to show something similar to an alert like SO does here with javascript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你需要做 ajax 轮询,用于在您编写答案时出现的“加载新答案”提醒。
这是 使用 jQuery 的 ASP.NET 教程
对于在开始键入答案/编辑帖子时尝试离开页面时的警报,请查看
onunload
事件。使用confirm
对话框,而不是警报
you'll need to do ajax polling for the "load new answers" alert that appears whilst you are writing an answer.
Here's a nice tutorial for ASP.NET using jQuery
For the alert when you attempt to navigate away from a page when you have started typing an answer/ editing a post, look at the
onunload
event. Aconfirm
dialog is used as opposed to analert
当您尝试离开评论/答案已部分填写的页面时,我们是否在谈论 SO 警告您?查看 Javascript 中的
onunload()
方法。有关示例,请参阅此处。Are we talking about SO warning you when you try to navigate away from a page with a partially filled in comment/answer ? Check out the
onunload()
method in Javascript. See here for an example.将此脚本添加到页面的头部:
add this script to the head portion of your page: