javascript - Twitter 如何做 noscript 重定向,有什么意义?

标签 javascript

Twitter 在他们的标签中有这个:

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

body 有这个:

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

我的问题是重定向到 ?_twitter_noscript=1 有什么意义,我该如何实现它?我尝试做类似的事情,但它无休止地尝试重定向。

最佳答案

您应该检查索引页面中的 $_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...
    }
?>

关于javascript - Twitter 如何做 noscript 重定向,有什么意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10484408/

相关文章:

javascript - BLUEPRINT Google Grid Gallery rtl 支持

javascript - 我可以将 HTML 元素中的属性传递给 JQuery .delay() 函数吗?

Javascript 跟踪音频/视频文件的播放次数(在 Qualtrics 中)

javascript - Google OAuth 按钮不起作用

javascript - 如何在 JQuery 中使用正则表达式(字段 $)将整数添加到字符串变量?

javascript - 如何将文件添加到 React-Redux 的状态中

javascript - 如何从JQuery函数中获取值

javascript - 使用 javascript 淡入/淡出播放/暂停音乐

javascript - $translateProvider.useStaticFilesLoader 的 Angular Translate 异步计时问题

javascript - 求和 jQuery 中的文本框列表