Jump to content

HTML If/Else

The Little Guy

Recommended Posts

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.

Link to post
Share on other sites

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?!

Link to post
Share on other sites

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 -->
<!-- MSIE (Microsoft Internet Explorer) will use inner object -->
<!-- [if!IE]> close outer object -->


Which by the way is not in any way related to html.


you can use java applets and add them to your HTML

Link to post
Share on other sites

Do you mean conditional comments such as....


<!--[if IE 5]>
<p>IE 5 spec stuff</p>


Because that has nothing to do with html, it is an IE specific behavour.


Where in the html documentaion are these conditionals?

Link to post
Share on other sites

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?

Link to post
Share on other sites

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">
		width: 100%;
<h1>Turn On your JavaScript</h1>
Congradulations! Your JavaScript Is Turned On!!!

Link to post
Share on other sites

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.

Link to post
Share on other sites

you can have a look on this as well:



<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html">



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)

Link to post
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.