Checking if browser is javascript enabled or not - Stack Overflow

<noscript><div>You must enable javascript to continue.<div><noscript>Ok this

<noscript>
    <div>
        You must enable javascript to continue.
    </div>
</noscript>

Ok this makes sense, but still, the contents after this element will be shown, of course in a bad way, but what I am looking for is this:

If javascript is NOT enabled, I want to show this alert message, and NOTHING ELSE, I don't want to give advice "It's better if you enabled Javascript", I want to FORCE, "You MUST ENABLED so you can Continue!", I don't wanna give access to my website if javascript is not enbaled, how can I do that?

<noscript>
    <div>
        You must enable javascript to continue.
    </div>
</noscript>

Ok this makes sense, but still, the contents after this element will be shown, of course in a bad way, but what I am looking for is this:

If javascript is NOT enabled, I want to show this alert message, and NOTHING ELSE, I don't want to give advice "It's better if you enabled Javascript", I want to FORCE, "You MUST ENABLED so you can Continue!", I don't wanna give access to my website if javascript is not enbaled, how can I do that?

Share Improve this question edited May 3, 2012 at 13:30 THelper 15.6k6 gold badges67 silver badges106 bronze badges asked May 1, 2012 at 17:48 Ali BassamAli Bassam 9,98924 gold badges70 silver badges119 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

Add a No-Javascript CSS class that hides everything else using CSS, and use Javascript to remove the class immediately (using an inline <script> block in that element).

<noscript>
    <div style='position:fixed;left:0;top:0;width:100%;height:100%;background:#f55;z-index=1000">
        You must enable javascript to continue.
    </div>
</noscript>

Also, your question wanted to throw an alert.. Which is JavaScript. You basically asked "how can I execute JS when JS is disabled?". But this HTML alone will do the trick.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745341472a4623346.html

相关推荐

  • Checking if browser is javascript enabled or not - Stack Overflow

    <noscript><div>You must enable javascript to continue.<div><noscript>Ok this

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信