t:SWITCH Element | switch Object

This topic documents a feature of HTML+TIME 2.0, which is obsolete as of Windows Internet Explorer 9.

Enables you to provide several choices and display content depending on which choice is true on the user's computer.

Members Table

The following table lists the members exposed by the switch object.

Attributes/Properties
Attribute Property Description
systemBitrate

Gets the approximate bandwidth available to the system in bits-per-second.

systemCaptions

Indicates whether to display a text equivalent of the audio portion of the presentation.

systemLanguage

Indicates whether a given language is selected in a user's system preferences.

systemOverdubOrSubtitle

Specifies whether overdubs or subtitles render during a presentation.

TIMECONTAINER timeContainer

Sets or gets the type of timeline associated with an element.

Remarks

Use the t:SWITCH element to decide which content to display based on the value of test attributes such as systemCaptions, systemBitrate, systemOverdubOrSubtitle, and systemLanguage.

This example detects the system language setting from the Regional Options in Control Panel and displays a text fragment in Spanish, Portuguese, or English, depending on the system language setting.


<t:switch>
  <span class="time" systemLanguage="es" >Somos interdependientes (Espanol)</span>
  <span class="time" systemLanguage="pt" >Nos somos interdependentes (Portuguese)</span>
  <span class="time" systemLanguage="en" >We are interdependent (English)</span>
  <span class="time">None of the above</span>
</t:switch>

Although different media-based elements exist, there is no functional difference in their current implementation. However, you are encouraged to use elements such as t:ANIMATION, t:AUDIO, t:IMG, t:MEDIA, t:REF, and t:VIDEO for improved document readability and enhanced support.

The prefix t: is used to associate this element with an XML namespace. You must declare the XML namespace in the html tag of your document when using this element.


<HTML XMLNS:t ="urn:schemas-microsoft-com:time">

You must then import the tag definitions from the time2 behavior by using the IMPORT processing instructions.


<?IMPORT namespace="t" implementation="#default#time2">

Within a switch block, all tags (including tags such as HR and BR) resolve true if they don't have valid test attributes. This has a couple of implications.

  1. The switch element is not effective as a time container for multiple elements because it stops rendering children after the first child resolves true. For this reason, the timeContainer attribute is ignored by the switch element.
  2. HTML comment tags always resolve true. To incorporate HTML comment tags in switch blocks, you must wrap them in another container, such as a DIV or t:PAR. The following code fragment demonstrates how to do this.

<t:switch>
  <div systemLanguage="en" >
    <!--This is the english language part -->
    ...
  </div>
  <t:par> 
    <!-- This is the catch-all part  -->
  </t:par>
</t:switch>

This element is not rendered.

This element requires a closing tag.

See Also

Community Additions

ADD
Show: