Mudsaf Posted August 27, 2013 Share Posted August 27, 2013 Hello, i'm wondering if there is reversed code for <noscript></noscript>, example if JavaScript is enabled add code there? Link to comment Share on other sites More sharing options...
Ingolme Posted August 27, 2013 Share Posted August 27, 2013 The <script> tag. If you want HTML elements to show up only if script is enabled, it is one of the few valid uses for document.write. Or you can use document.createElement and append them to something. <script> document.write("<p>Javascript is enabled.</p>");</script> <div id="script"></div><script> var p = document.createElement("p"); p.innerHTML = "Javascript is enabled."; document.getElementById("script").appendChild(p);</script> A third method: <div id="script" style="display: none">Javascript is enabled</div><script> document.getElementById("script").style.display = "block";</script> Link to comment Share on other sites More sharing options...
Mudsaf Posted August 27, 2013 Author Share Posted August 27, 2013 The <script> tag. If you want HTML elements to show up only if script is enabled, it is one of the few valid uses for document.write. Or you can use document.createElement and append them to something. <script> document.write("<p>Javascript is enabled.</p>");</script> <div id="script"></div><script> var p = document.createElement("p"); p.innerHTML = "Javascript is enabled."; document.getElementById("script").appendChild(p);</script> A third method: <div id="script" style="display: none">Javascript is enabled</div><script> document.getElementById("script").style.display = "block";</script> What you recommend, messy code or clean interface for non-JavaScript users? Link to comment Share on other sites More sharing options...
Ingolme Posted August 27, 2013 Share Posted August 27, 2013 Making sure that the website works for as many users as possible is a good idea. I wouldn't call that code messy. Link to comment Share on other sites More sharing options...
Mudsaf Posted August 27, 2013 Author Share Posted August 27, 2013 Making sure that the website works for as many users as possible is a good idea. I wouldn't call that code messy. Doesn't google reCaptcha work without JavaScript? I'll get message below. <iframe src="http://www.google.com/recaptcha/api/noscript?k=6Lc7VdASAAAAADcvby26Vavw4lw47jQwCHDU7EKv" height="300" width="500" frameborder="0"></iframe><br/> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/> Link to comment Share on other sites More sharing options...
Mudsaf Posted August 27, 2013 Author Share Posted August 27, 2013 (edited) Ah works but now i have google reCaptcha charset problem. Edited August 27, 2013 by Mudsaf Link to comment Share on other sites More sharing options...
Ingolme Posted August 27, 2013 Share Posted August 27, 2013 I can't see how Javascript could cause that problem. What does your code look like? Link to comment Share on other sites More sharing options...
Mudsaf Posted August 27, 2013 Author Share Posted August 27, 2013 Well the code displays this. <noscript><iframe src="http://www.google.com/recaptcha/api/noscript?k=6Lc7VdASAAAAADcvby26Vavw4lw47jQwCHDU7EKv" height="300" width="500" frameborder="0"></iframe><br/> <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/></noscript Displays sometimes on page like that or messes up the charsets of finnish ä letter. (Attachment @ my last post) Link to comment Share on other sites More sharing options...
Ingolme Posted August 27, 2013 Share Posted August 27, 2013 I don't see any Javascript there. Make sure your text editor is saving the HTML file as UTF-8 Link to comment Share on other sites More sharing options...
davej Posted August 28, 2013 Share Posted August 28, 2013 I don't think there are many large modern websites that work correctly with Javascript turned off. I don't even see the option to disable Javascript listed in Firefox options menu anymore. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now