I know how to display content if JavaScript is disabled, but what I want to do is make a div suddenly appear even if the page is open at the time of JavaScript being disabled.
- The page is opened.
- The user goes to browser settings and disables JavaScript.
- A div shows without refreshing the page.
How can I do this? I’ve seen other sites do this but I looked at their JavaScript files and didn’t find anything in it.
Thanks in advance!
Here’s a solution using CSS animations. They’re not supported everywhere, but I can’t think of any alternative.
This hides your message by giving it a
font-sizeof0, which is reset to100%after a delay of one second. Every half-second the JavaScript restarts the animation by switching to a dummy animation which keeps the element hidden. (Demo on jsfiddle)HTML
CSS
JavaScript
You would need to duplicate all of the
webkitprefixed properties with the other vendor prefixes; I’ve omitted them here for clarity.