一: 加本站臨時鏈接,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