The Little Guy Posted July 28, 2008 Share Posted July 28, 2008 Using the HTML IF/ELSE conditions, is it possible to not show some of the page if the user has JavaScript turned off? Quote Link to comment Share on other sites More sharing options...
trq Posted July 28, 2008 Share Posted July 28, 2008 There is no if else in html, it is a simple markup language. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 28, 2008 Author Share Posted July 28, 2008 HTML does support it, I had to do it in my Java Class. Quote Link to comment Share on other sites More sharing options...
trq Posted July 28, 2008 Share Posted July 28, 2008 It does not support it, it is not a programming language. Maybe you need to resit this Java class? Which by the way is not in any way related to html. Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 28, 2008 Share Posted July 28, 2008 There are HTML conditional statements, I've generally seen them (and have used them) when loading browser-specific stylesheets. As far as I'm aware, they have nothing to do with JavaScript so you should get the same results with JS switched on or off. Though, it triggers the thought - Surly it would be quicker to just switch JavaScript off in your browser and test it, rather than ask on a forum what might happen?! Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 28, 2008 Author Share Posted July 28, 2008 ha! your right, my instructor was just using them as comments, I thought they were actually doing something. my mistake. <!-- [if!IE]> Firefox and others will use outer object --> 1 <!--<![endif]--> <!-- MSIE (Microsoft Internet Explorer) will use inner object --> 2 <!-- [if!IE]> close outer object --> 3 <!--<![endif]--> Which by the way is not in any way related to html. you can use java applets and add them to your HTML Quote Link to comment Share on other sites More sharing options...
trq Posted July 28, 2008 Share Posted July 28, 2008 Do you mean conditional comments such as.... <!--[if IE 5]> <p>IE 5 spec stuff</p> <![endif]--> Because that has nothing to do with html, it is an IE specific behavour. Where in the html documentaion are these conditionals? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 28, 2008 Author Share Posted July 28, 2008 Well, what I want to do is sort of like meebo. If you view the home page with javascript on, it comes up normal, if you don't, it shows no login boxes or anything, just plan text telling you to turn on javascript to login. how do thay do that? Quote Link to comment Share on other sites More sharing options...
zq29 Posted July 28, 2008 Share Posted July 28, 2008 <noscript></noscript> maybe? Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted July 28, 2008 Share Posted July 28, 2008 Render the elements using Javascript's DOM interface. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 28, 2008 Author Share Posted July 28, 2008 OK, I see they just use styles, and I guess that the styles don't show up when javascript is turned on. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Hw1</title> <style> noscript{ width: 100%; display:block; position:absolute; bottom:0; top:0; background-color:#FFF; } body{ padding:0; margin:0; } </style> </head> <body> <noscript> <h1>Turn On your JavaScript</h1> </noscript> <div> Congradulations! Your JavaScript Is Turned On!!! </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
tibberous Posted July 29, 2008 Share Posted July 29, 2008 Those do do something, in IE. Quote Link to comment Share on other sites More sharing options...
haku Posted July 31, 2008 Share Posted July 31, 2008 If you want something only to be visible when javascript is on, then in the html/css code, set the element's display property to none. Then, in the window.onload function, set the display property of that element to either block or inline. In this way, the element will never be made visible if the user has javascript off, and if they have it on, when the window is done loading, the element will be made visible. Quote Link to comment Share on other sites More sharing options...
vikramjeet.singla Posted July 31, 2008 Share Posted July 31, 2008 you can have a look on this as well: <noscript> <META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html"> <noscript> Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted July 31, 2008 Share Posted July 31, 2008 you can have a look on this as well: <noscript> <META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html"> <noscript> You shouldn't do that. meta is not allowed inside noscript according to the DTD. Furthermore: Note. Some user agents support the use of META to refresh the current page after a specified number of seconds' date=' with the option of replacing it by a different URI. Authors should not use this technique to forward users to different pages, as this makes the page inaccessible to some users. Instead, automatic page forwarding should be done using server-side redirects.[/quote'] Here is an excerpt from the XHTML 1.0 Strict DTD (HTML 4.01 looks almost the same): <!ENTITY % misc.inline "ins | del | script"> <!ENTITY % misc "noscript | %misc.inline;"> <!ENTITY % heading "h1|h2|h3|h4|h5|h6"> <!ENTITY % lists "ul | ol | dl"> <!ENTITY % blocktext "pre | hr | blockquote | address"> <!ENTITY % block "p | %heading; | div | %lists; | %blocktext; | fieldset | table"> <!ENTITY % Block "(%block; | form | %misc;)*"> <!ELEMENT noscript %Block;> (Oddly enough, this allows you to use script inside noscript and another noscript may appear inside the first noscript) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.