一: 加本站临时链接,url在新开窗口打开
思路: 让链接跳转到一个out.html 网页中
该网页的内容:
<html>
<head>
<meta charset="utf-8">
<style type="text/css" media="screen">
iframe{
display: none;
}
</style>
<body onLoad="open_without_referrer()">
<script>
function open_without_referrer(){
var link = encodeURI('{$url}');//url为跳转链接
document.body.appendChild(document.createElement('iframe')).src='javascript:"<script>top.location.replace(\''+link+'\')<\/script>"';
}
</script>
</body>
</html>
二: 不加本站临时链接,url在原窗口打开
思路: 将上述html中的script在本页面中封装成function 使用
function openWithoutReferrer(url){
document.body.appendChild(document.createElement('iframe')).src='javascript:"<script>top.location.replace(\''+url+'\')<\/script>"';
}
三: 不加本站临时链接 ,url在新窗口打开
思路:在原页面中script中封装function 并调用
function openWithoutReferrer(url){
window.open('javascript:window.name;', '<script>location.replace("'+url+'")<\/script>');
}
解决js中window.open弹出的是上次的缓存页面问题
function openWithoutReferrer(url){
var oDate = new Date();
window.open('javascript:window.name', '<script>location.replace("'+url+'")<\/script>'+oDate.getTime());
}
附:
1.php查询网站页面跳转referrer信息
dump($_SERVER['HTTP_REFERER']);
2.script 开新链接
window.location.href = url;//本窗口打开url
window.open(url);//新窗口打开url