+ 2

How can I test the presence of javascript without <noscript>

Withoit HTML tags pls

27th Mar 2018, 6:10 PM
Here's Johny
Here's Johny - avatar
4 Respostas
+ 3
Why do you want to avoid use of <noscript>? The only reason I can guess, is the need to style (css) differently document (or part of it) regarding of presence or not of JS (if it's only to display a specific message in case of JS not available, <noscript> element is well designed for, even if you could follow @John Wells advice)... in this case, in same way as @John Wells advice, give default specific style for no JS, and with JS add dynamically a class name to the <body> element (or remove it), then define style for JS present by prepend the class name to the css rules you want to be applied when JS is present (or inverse): <style> p { color: blue; } .js p { color: red; } </style> <body> <p>default styled to blue, red if body get 'js' class name</p> <script> document.body.className = "js"; </script> </body>
27th Mar 2018, 7:43 PM
visph
visph - avatar
+ 3
Default the document to your message and use JS to change it. If they don't have it, they get your error message. Otherwise, they get your program.
27th Mar 2018, 6:29 PM
John Wells
John Wells - avatar
+ 1
alert("Test - Yup, it's working!"); Basically, you can test it by doing anything that uses Javascript.
27th Mar 2018, 6:12 PM
Fata1 Err0r
Fata1 Err0r - avatar
0
And if user dont have JS, how can i write something like "Bro, you don't have javascript"
27th Mar 2018, 6:23 PM
Here's Johny
Here's Johny - avatar