<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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With