ホームページ > 記事 > ウェブフロントエンド > JavaScript基本Q&A2_基礎知識
4. JavaScript的局限性(JavaScript Lminitations)
Q:JavaScript程序不能做什么?
A:JavaScript代码不能做下列事情:
(解决方法,见打印JavaScript输出。)
(解决方法,见文件访问部分。)
(解决方法,见文件访问部分。)
如果你的确需要访问文件或者执行其他“特权”操作,可以JavaScript和Java applet结合使用。已签名的Java applet允许进行特权操作,同时,JavaScript可以和applet交换信息。然而,你必须明白JavaScript/Java最大的限制是:用户可能一直禁止使用JavaScript或者Java或者二者。
5. 支持JavaScript的浏览器(Browsers Supporting JavaScript)
Q:那些浏览器支持JavaScript?
A:下列浏览器都支持JavaScript:
6. JavaScript的版本(JavaScript Versions)
Q:JavaScript有哪些版本?
A:JavaScript是新兴的编程语言之一。它第一次实现是有Netscape社区在1995完成。第一个支持JavaScript的浏览器是Netscape Navigator 2.0 beta 版。截止1999年,两大主流浏览器,Netscape Navigator和Microsoft Internet Explorer对客户端JavaScript主要支持以下版本:
浏览器 |
年份 |
JavaScript版本 |
Netscape Navigator 2.0 | 1995 | JavaScript 1.0 |
Microsoft Internet Explorer 3.0 | 1996 | JavaScript 1.0 (JScript 1.0) |
Netscape Navigator 3.0 | 1996 | JavaScript 1.1 |
Netscape Navigator 4.0 | 1997 | JavaScript 1.2 |
Microsoft Internet Explorer 4.0 | 1997 | JavaScript 1.2 (JScript 3.0) |
Netscape Navigator 4.5 | 1998 | JavaScript 1.3 |
Microsoft Internet Explorer 5.0 | 1999 | JavaScript 1.3 (JScript 5.0) |
Unfortunately, Netscape and Microsoft's JavaScript implementations are different, even with the same version number of JavaScript. For example, JavaScript 1.0 in IE3 is different from JavaScript 1.0 in Netscape Navigator 2; similarly, JavaScript 1.2 in IE4 is different from JavaScript 1.2 in Netscape Navigator 4.
In addition to these versions, third parties can also create their own JavaScript implementations, or license Microsoft or Netscape's JavaScript technology. For example, the Opera browser supports JavaScript.
What does cross-platform coding mean? Essentially, you have to use one of the following techniques:
7. JavaScript documentation (JavaScript Documentation)
Q: Where can I get documentation for JavaScript?
A: Online JavaScript documentation can be found at these sites:
In addition, you can also find JavaScript discussions, online guides, links, code samples, and hundreds of useful scripts from the following websites (of course this list is not exhaustive and is only used as a starting point):
8. Printing JavaScript Output (Printing JavaScript Output)
Q: How do I print JavaScript output?
A: JavaScript programs cannot directly access the printer. However, by going to File | Print in the browser menu (or using the shortcut, Ctrl P on Windows), users can print anything on the web page, including the output of JavaScript programs.
If users need to print your script output frequently, then you can:
Alternatively, your script can generate print content in a separate browser window (see example below).
Example: This script generates a multiplication table, outputs it to a new browser window, and explains to the user how to print it.