1.有时候我们会在点击链接地址之前需要JS操作一段功能后在连接到需要的地址,我们可以先写一段JS 来实现
如:
<a href='http://www.sina.com.cn'>新浪</a>
在点连接的时候触发一个提示消息,修改如下:
<a href=JavaScript:openFileMessageOver('http://www.sina.com.cn‘);>新浪</a>
JS
function openFileMessageOver(url){ alert("hello"); window.location=url; }
这样在
window.location
之前触发一个事件。