手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

如何实现链接只能访问一次

时间:2024-10-20 09:06:45

1、第一种:利用JS在点击后把href变成#把taget变成空。<p><a onclick="var that = this;setTimeout(function(){that.removeAttribute('href');that.onclick=that=null;}, 0);return true;" href="http://www.g.cn" target="_blank">Open Google in New Window</a></p>Open Google in New Window提示:你可以先修改部分代码再运行。

2、第二种:利用JS在点击后删除href属性,使链接变为文字。兼容IE6,IE7,IE8,Fi筠续师诈refox,Opera,Safari,Chr泠贾高框ome<p><a onclick="var that = this;setTimeout(function(){that.removeAttribute('href');that.onclick=that=null;}, 0);return true;" href="http://www.g.cn" target="_blank">Open Google in New Window</a></p>Open Google in New Window提示:你可以先修改部分代码再运行。

3、第三种:设置href值及target值的一种做法<p><a onclick="this._clk?(this.href='javascript:;',this.target='_self'):(this._clk=1);" href="http://www.google.cn" target="_blank">Open Google in New Window</a></p>

© 手抄报圈