When your web application includes the use of CGI scripts, another approach to all forms of JavaScript compatibility is to use a CGI script on your web server to generate all the JavaScript code used in your application. Then, this script can inspect the User-Agent field of the HTTP request header. This allows it to determine exactly what browser the user is running and generate customized JavaScript code that is known to work correctly on that browser. And if the CGI script detects that the user's browser does not support JavaScript, it can generate web pages that do not require JavaScript at all. The only drawback to this approach is that the CGI script cannot detect when a user has disabled JavaScript support in their browser.
Using a CGI script is also an ideal way to handle the SRC attribute of the <SCRIPT> tag. If the CGI script detects a browser that supports this attribute, it can trivially generate a web page that simply contains a reference to its JavaScript code. For other browsers, it can include that JavaScript code literally into the web page.
The Navigator.userAgent property contains the string that a browser sends as its User-Agent HTTP header. See the reference page for this property for more information. Note that writing CGI scripts is well beyond the scope of this book. For more information on doing so, see CGI Programming on the World Wide Web by Shishir Gundavaram, published by O'Reilly & Associates.
file: /Techref/language/java/script/definitive/ch18_04.htm, 4KB, , updated: 2019/10/14 15:00, local time: 2024/11/15 02:06,
18.219.86.191:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/techref/language/java/script/definitive/ch18_04.htm"> [Chapter 18] 18.4 Compatibility Through CGI Scripts</A> |
Did you find what you needed? |