js实现。

1、借助一个新页面跳转到目标地址。

<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>

2,直接跳转到目标地址,在原窗口打开。

function openWithoutReferrer(url){
    document.body.appendChild(document.createElement('iframe')).src='javascript:"<script>top.location.replace(\''+url+'\')<\/script>"';
}

3,直接跳转到目标地址,在新窗口打开。

function openWithoutReferrer(url){
     window.open('javascript:window.name;', '<script>location.replace("'+url+'")<\/script>');
}

如果要避免各种原因出现的缓存导致错误,我们在跳转时候加入当前时间。

function openWithoutReferrer(url){
    var oDate = new Date();
    window.open('javascript:window.name', '<script>location.replace("'+url+'")<\/script>'+oDate.getTime());
}

标签: none

添加新评论