HTML and CSS Reference
In-Depth Information
value is "" . If that is the case, the code that has called this function might need to be written
in a way to catch that condition and alter the program execution. We did that with the test of
the return value and the alert() message, which we described in the previous section.
If you want to test the error condition with no valid return value from this function, simply add an
extra character to the MIME type (for example, audio / oggx ) to make sure an empty string is always
Alternatively, you can use Modernizr to test for audio support. If you have included the
Modernizr JavaScript library in your HTML page (as we have done in every application we
have written thus far), you can access the static values of , Modern- ,and totesttoseewhetherthosetypesarevalid.Theseare
not Booleans—they evaluate to the same probably , maybe , and "" values that we get from
a call to canPlayType() . If you are comfortable using Modernizr for all your tests, you can
replace the test in the code with tests of these Modernizr static values.
Search WWH ::

Custom Search