2012-05-07 16 views
3

Twitter也有這自己的標籤內:Twitter如何做無腳本重定向?有什麼意義?

<noscript> 
<meta http-equiv=refresh content="0; URL=/?_twitter_noscript=1" /> 
</noscript> 

機身擁有這樣的:

<noscript> 
    <div class="front-no-js-warn"> 
     <h3>Twitter.com makes heavy use of JavaScript</h3> 
     <p>If you cannot enable it in your browser's preferences, you may have a better experience on our <a href="http://m.twitter.com">mobile site</a>.</p> 
    </div> 
    </noscript> 

與CSS:

.front-no-js-warn{position:absolute;top:50px; 
left:50%; 
height:30px; 
width:798px; 
padding:15px 20px; 
margin:0 0 0 -418px; 
z-index:2;color:#ddd; 
line-height:1.5; 
background-color:#111; 
background-color:rgba(20,20,20,.9); 
-webkit-border-radius:6px; 
-moz-border-radius:6px; 
border-radius:6px; 
} 
.front-no-js-warn h3{color:#FEC632;font-weight:bold;} 
.front-no-js-warn a{color:#75C6F7;} 

所以,當你禁用了Javascript,你看div class="front-no-js-warn"

我的問題是r的意義編輯爲?_twitter_noscript=1,我該如何實現?我試着做類似的事情,它無休止地嘗試重定向。

+0

你可能會重定向到同一頁面?您需要重定向到不包含重定向的網址。 '?_twitter_noscript = 1'可能會告訴服務器修改頁面或發送一個不同的頁面。 –

回答

2

你應該檢查$ _GET ['_ twitter_noscript = 1'](php)在你的索引頁面,如果它存在顯示一個不同的頁面。

例子:

<?php 
    if ($_GET['_twitter_noscript']) { 
     echo "Display javascript-less page"; 
    } else { 
     echo "noscript...meta refresh... etc etc ... /noscript"; 
     //Rest of the page... 
    } 
?> 
+0

謝謝!我想知道如果no-javascript警告div被包裝在

1

他們這樣做,以便他們可以確定哪些用戶禁用JavaScript,並讓他們知道,因爲他們不會體驗Twitter所提供的所有內容。