Back to the original French page Read this page in Italian by Google Translation Read this page in Portuguese by Google Translation Read this page in English by Google Translation Read this page in German by Google Translation Read this page in Spanish by Google Translation Read this page in Arabic by Google Translation Read this page in Hebrew by Google Translation

Alternatives to JavaScript

Go to the beginning of the content without using the bar Consultation and Sharing How to use the bar Consultation and Sharing Listen to the main content of this page
Print Print the main content of this page Send Email the main content of this page Share Share on TwitThis Share on Facebook Share this page on Wikio Share this page on Google Share on LinkedIn Share on Digg Share this page on del.icio.us Share this page on Netvibes

Warning: the original version of this document is Creating Accessible JavaScript: JavaScript Alternative . This French translation was done by Ideos under an agreement between WebAIM and Ideos .

Note: See page documents on web accessibility for a list of all translated documents. Other resources on web accessibility are also listed in the digital portal accessible .

Introduction

Whenever the JavaScript can not be made directly accessible, an accessible alternative must be provided. Indeed, many user agents, such as mobile phones with web browsing and PDAs are not yet able to use JavaScript. There are several ways to provide alternatives accessible when the script can not be made available or when the user does not have JavaScript.

Server-side processing

In many cases, the functionality provided by JavaScript can be duplicated by a server-side script. For example, JavaScript is often used to validate form data before the form is sent. Instead of implementing these programs, and JavaScript techniques associated access, you can use a server-side script to validate the form data. JavaScript is often used to write dynamic information on a Web page, such as the date and / or the current time. Again, use a server-side script eliminates the need to implement techniques for accessibility.

Use the tag <noscript>

Making JavaScript natively accessible is very important. However, in some cases, end users may not have JavaScript enabled or may use technology that does not support JavaScript (for example, mobile phone, PDA, etc.).. In this case, you must provide alternative non-JavaScript for users who can not or chooses not to display the content JavaScript.

When JavaScript is used in a Web page, the easiest way to offer an alternative to JavaScript generated content is to provide content within the tag <noscript> . The tag <noscript> can be used in your page to display content in browsers that do not support or have disabled JavaScript. However, if JavaScript is enabled tag <noscript> is ignored.

Important

Provide an accessible alternative to the tag <noscript> inaccessible for a script will not make the page accessible. The tag <noscript> only display the content if JavaScript is disabled. Most users have a screen reader with Javascript enabled. Therefore, screen readers will read the script inaccessible and not the content of the tag <noscript> .

The tag <noscript> provides alternate text for JavaScript. If the content or functionality of this script need an alternative accessible when JavaScript is disabled, you must use the tag <noscript> . The contents of the tag <noscript> should ideally contain the equivalent content or functionality that is provided by the script. However, it is often impossible. It is not enough to simply state, "Your browser does not support JavaScript." This does not change the content accessible. You can, for example, provide a link to an alternative accessible HTML, or a page that uses server-side scripts instead. Or at least, describe the type of content that would be displayed if JavaScript is enabled.

The tag <noscript> should be used whenever an alternative or a non-JavaScript content is required.

<script type= »text/javascript »>
<! - Document.write ("Time Now ets:" + currentTime) ->
</ Script>
<noscript>
<! - Link to a page that displays the time by a server-side script ->
<a href= »time.htm »> View now </ a>
</ Noscript>

Example <noscript>

In the following example, two buttons forms are provided in the HTML. If you have JavaScript command document.write inside the tag <script> displays the first button. If this button is selected, it triggers a JavaScript function that can be used to validate and submit the form using JavaScript additional page. If JavaScript is not enabled, then the button in the tag <noscript> is displayed, the form data could be sent to a server-side script, which then provide feedback and validation for the form.

Test the sample with <noscript>

<script type= »text/javascript »>
<! -
document.write ('<input type= »button "value= »Submit" onclick= »validateForm(); "/>');
->
</ Script>
<noscript>
<p>
<input type= »submit "value= »Submit »>
</ P>
</ Noscript>

WebAIM is an initiative of:
Center for Persons with Disabilities (CPD) Utah State University

Copyright 1999-2009 WebAIM

Top of Page