Let's say I have Flash-version of and non-Flash version of my website. When a user comes to my website, is there any way to create the following logic:
if (user has flash-plugin installed) { load flash website }
else { load non-flash website }
While we are here. Can I do the same for the bandwidth control? Let's say a Cable customer visits my websites. He has no problem loading my 10mb fully loaded flash website with background videos. But if someone with a slow internet connection visits my website, can I skip the Flash website and re-direct that user to non-Flash website?
If there's no way to accomplish this, is there any workaround, any at all?
Thanks in advance!
You can not use the If else condition in HTML code (Without JavaScript). Because HTML is a markup language and not a programming language. You need to do logic codes either server-side or with Javascript.
Logical tags are used to tell the browser what kind of text is written inside the tags. They are different from physical tags because physical tags are used to decide the appearance of the text and do not provide any information about the text.
Definition and Usage. The if/else statement executes a block of code if a specified condition is true. If the condition is false, another block of code can be executed. The if/else statement is a part of JavaScript's "Conditional" Statements, which are used to perform different actions based on different conditions.
If you are getting an error about the else it is because you've told the interpreter that the ; was the end of your if statement so when it finds the else a few lines later it starts complaining. A few examples of where not to put a semicolon: if (age < 18); if ( 9 > 10 ); if ("Yogi Bear". length < 3); if ("Jon".
HTML has a limited set of "if/else" test on the browser's capabilities, e.g. whether it can handle scripts (<noscript>
), frames (<noframes>
), etc.
Your case on Flash-plugins can be handled by fallback content of <object>
, for example:
<object type="application/x-shockwave-flash" data="x.swf" width="400" height="300">
<param name="movie" value="x.swf" />
<p>Your browser does not support Flash etc etc etc.</p>
</object>
(See Providing alternative images if Adobe Flash isn’t available for more alternatives.)
But it's not possible to have a bandwidth control with HTML alone.
You must use javascript. Here is a plugin detection tool on JS.
http://www.oreillynet.com/pub/a/javascript/2001/07/20/plugin_detection.html
var isFlashInstalled = detectFlash();
if (isFlashInstalled)
{
window.location = "main_with_flash.htm";
}
else
{
window.location = "main_no_flash.htm";
}
No, this is not doable in pure HTML. You would need the assistance of JavaScript, or maybe a server-side language like PHP, or Server Side Includes (although detecting Flash is best done using JS.)
The only "if/else" there is is for the presence of JavaScript. Anything inside a noscript
tag will be shown only in browsers that don't support JavaScript or have it turned off.
<noscript>You have JavaScript turned off!</noscript>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With