Skip to content

Instantly share code, notes, and snippets.

@jtyjty99999
Last active August 29, 2015 13:57
Show Gist options
  • Save jtyjty99999/9615107 to your computer and use it in GitHub Desktop.
Save jtyjty99999/9615107 to your computer and use it in GitHub Desktop.
点击链接不发送referer
//用window.open的方式打开一个中转页面,再在里面执行代码打开(新窗口打开)
function open_new_window(full_link){
window.open('javascript:window.name;', '<script>location.replace("'+full_link+'")<\/script>');
}
//其中location.replace刷新页面的方式也可以替换成html自刷新的方式
var html = '<html><head><meta http-equiv='Refresh' content='0; URL=" 路径 + "' /></head><body></body></html>'
var a = window.open(null, 打开方式(_self或者_blank))
a = a.document;
a.clear();
a.write(e);
a.close();
//用iframe添加到body后,仍然用javascript的方式替换链接
function open_without_referrer(link){
document.body.appendChild(document.createElement('iframe')).src='javascript:"&lt;script&gt;top.location.replace(\''+link+'\')&lt;\/script&gt;"';
}
//用data schema的方式替换href,仍然打开一个刷新器
var html = '<html><head><meta http-equiv='Refresh' content='0; URL=" 路径 + "' /></head><body></body></html>'
html = encodeURIComponent(html)
$(链接).click(function (){
this.href = html;
return !0
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment