如何使用Meteor.com检测是否禁用了JavaScript

时间:2013-12-03 05:48:21

标签: meteor javascript

使用Meteor.com时,任何人都知道如何检测浏览器的JavaScript是否被禁用...

在浏览器窗口中向最终用户显示一条消息,即“打开JavaScript。”

3 个答案:

答案 0 :(得分:3)

我假设您有layout.html或至少main.html,其中至少包含<head>

一个技巧是将<noscript> 放在<head> 而不是<body>

Meteor不能在JS中呈现所有内容。有一些东西可以在初始页面中呈现,其中的证据可以在查看源中看到( CTRL + U < / KBD>)。

答案 1 :(得分:1)

我在Chrome中使用了最新的Meteor,并且没有合并头标记。只有这对我有用:

Paragraph p = Body.Descendants<Paragraph>().Where(p.InnerText.Contains(searchString)).FirstOrDefault();
if (p != null)
{
    // Here follow the link Ron post to create a comment
    // insert the comment into p with p.InsertAfter() as said in the link
}

答案 2 :(得分:1)

我刚用过它,它确实像魅力一样工作

<head>
<noscript>
<style>
body {font-size: 32px;text-align: center;line-height: 100vh;}
body:after {content: "Please enable JavaScript";}
</style>
</noscript>
</head>