use*_*506 0 javascript jquery replace href
使用jQuery,我试图<a href="/folder/whatever.file">link</a>在页面上找到任何实例并将http://www.domain.com放在/ folder之前.
最简单,最安全的方法是什么?
单击时更新锚标记的href.
$(document).on("click","a:not([href^=http])",function(){
this.href = "http://domain.com" + this.href;
})
Run Code Online (Sandbox Code Playgroud)
还是更好
$(document).on("click","a[href^=/specificfolder/]",function(){
this.href = "http://domain.com" + this.href;
});
Run Code Online (Sandbox Code Playgroud)
使用htaccess或类似的url重写解决方案在您的服务器上进行此更改可能会更好.
| 归档时间: |
|
| 查看次数: |
885 次 |
| 最近记录: |