[英]Display text when user clicks on any link
I want to display my licence agreement when the user clicks on any link on the page and prevent the link from taking the user anywhere. 当用户单击页面上的任何链接时,我想显示我的许可协议,并阻止该链接将用户带到任何地方。 I need a way to make any click on the page show the code I want.
我需要一种方法来使页面上的任何单击都显示我想要的代码。 Is there an easy way to do it?
有一个简单的方法吗? Like a scripts that tells the browser "when the user clicks something show this...".
就像脚本告诉浏览器“当用户单击某项时显示此...”。
Thanks a lot for any info 非常感谢您提供任何信息
Plain javascript (but without any test for existing onclick handlers): 普通的javascript(但不对现有的onclick处理程序进行任何测试):
in the head add 在头部添加
<script>
var disclaimer="This link is not our responsibility - click ok to continue"
window.onload=function() {
var links = document.links;
for (var i=0, n=links.length;i<n;i++) {
links[i].onclick=function() { return confirm(disclaimer);}
}
}
</script>
Jquery: jQuery的:
$('a').click(function() {
// show whatever you want
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.