毕业设计外文翻译-深入浅出JavaScript_第1页
毕业设计外文翻译-深入浅出JavaScript_第2页
毕业设计外文翻译-深入浅出JavaScript_第3页
毕业设计外文翻译-深入浅出JavaScript_第4页
毕业设计外文翻译-深入浅出JavaScript_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、精选优质文档-倾情为你奉上毕业设计(论文)外文资料翻译题 目: Beginning JavaScript with DOM Scripting and Ajax 深入浅出JavaScript学 院: 信息工程学院 系 计算机 专 业: 计算机科学与技术班 级: 学 号: 姓 名: 指导教师:起讫日期:专心-专注-专业外文资料翻译译文深入浅出JavaScript1.1 JavaScript产生的原因在Web发展的初期,主要有HTML和公共管理接口(GUI)。HTML定义了大部分的文本文档并且只是用户代理(通常为网页浏览器)如何显示。比如,标签<p></p>之间的文字就会成

2、为一个段落,在这个段落中可以使用标签<h1></h1>来定义最主要的页面标题。注意大多数开始标签,都会有相应的以</开头的结束标签。HTML有一个缺点,即他的状态是固定不变的。如果想改变一些东西或者使用用户输入的数据,就需要向服务器提出一个往返的请求。使用动态技术(如ColdFusion、ASP、ASP.NET、PHP或JSP)就可以从表单或者参数中将信息发送到服务器然后通过服务器完成计算、测试、数据库查找等。与这些技术相关联的应用程序服务器则会产生一个HTML文档来显示结果,然后把处理的结果一HTML文档的形式返回到浏览器以供用户查看。这样做的问题在于无论何时网

3、页只要有变化,以上整个过程都需要再重复执行一遍(并且重新加载网页)。这样会显得比较笨重缓慢,没有网络这个新媒介对我们承诺的那么美好。现在,人们已经普遍拥有了快速的因特网连接。但是显示一个页面仍然意味着重新加载,这是一个时常失败的缓慢过程(遇到过Error 404没有?)。我们需要更加灵活的东西要允许Web开发人员快速地对用户给予反馈并且不用从服务器重新加载页面就能改变HTML。可以想象有这么一个表单,只要有一个字段中产生了错误,它都需要重新加载,如果能够不用重新从服务器加载页面,就能快速地获取错误提示,那岂不是更方便实用?这正是JavaScript的用武之地。一些信息(比如表单上的一些计算和验

4、证信息)并不需要依靠服务器。JavaScript可以由访问者电脑上的用户代理(通常是一个浏览器)来执行。我们把这叫做客户端代码(client-side code)。这样可以减少与服务器的交互成本并且使网站运行得更快。1.2 JavaScript是什么JavaScript的前身是LiveScript,但是网景公司后来把名字改成了JavaScript,很可能是由于Java的火爆。这个名字经常会令人感到迷惑,因为尽管Java与JavaScript有些语法比较相近,但它们之间并没有必然的联系。Java之于JavaScript就好比Car(汽车)之于Carpet(地毯)。来自Usenet上的JavaSc

5、ript讨论组网景公司在1996年创造了JavaScript语言,它包含在Netscape Navigator(NN)2.0浏览器中,用解释器来读取和执行添加到.html页面的JavaScript代码。从此,这种语言稳步发展壮大并越来越普及,现在大多数浏览器都支持它。这意味着JavaScript可以用于网页中,被所有现代的浏览器所解释。但是,不同的浏览器在实现JavaScript的方式上是不同的,尽管核心的JavaScript语言是一样的。不过,JavaScript可以被用户关闭掉,并且一些公司和机构从安全的角度考虑要求他们的用户这样做。这个我们稍后(贯穿本书)会进一步讨论。关于JavaScr

6、ipt最大的特点就是,一旦学会了如何在浏览器编程中使用它,你就可以把它应用到其他的领域中。微软的服务器使用JavaScript去做服务器端网页编程(ASP),PDF文件现在也在使用JavaScript,甚至Windows的任务管理也可以使用JavaScript来自动运行。许多应用程序,如Dreamweaver和Photoshop,都可以使用JavaScript来编写脚本。操作系统上的许多插件,比如苹果公司的Dashboard或者Linux和Windows平台上的Konfabulator,甚至允许使用JavaScript编写小的帮助程序。最近许多大公司也提供了可用在网页中的JavaScript对

7、象和方法组成的API(应用编程接口),Google Maps就是其中的一种。只需要使用几行代码就可以在你的网站中提供可缩放和可滚动的地图。另一个更好地特点就是,JavaScript比高级编程语言和服务器端编程更容易开发。它不需要像Java和C+那样编译,也不需要像Perl、PHP或Ruby语言那样运行在服务器上或需要在命令行执行。编写、执行、调试和应用JavaScript脚本所需要的只是文本编辑器和浏览器,而这两者在所有的操作系统上都提供。当然,也有工具可以使你更加方便,如Mozilla Venkman、Microsoft Script Debugger和kjscmd这样的JavaScript

8、调试器。1.3 JavaScript的问题和价值正如我在本章的开始提到的,JavaScript在过去的几年里就已经成为Web开发的一个完整的部分,但是它也经常被错误地使用。结果,它就落了一个不好的名声。导致这个结果的原因是某些严重影响用户的JavaScript特效,如移动的页面元素和弹出窗口。这种情况你第一次看到印象会很深刻,但很快就变成了“有了也不错”,在有些情况下,甚至变成“没有更好”。许多类似的效果都来自DHTML时代(相见第3章)。术语用户代理(user agent)和对其含义的缺乏理解同样也是一个问题。通常,用户代理是指一个浏览器,比如微软的IE,Netscape、Mozilla(M

9、oz),Firefox(Fx)、Opera或Safari。但是浏览器不是web上唯一的用户代理,其他用户代理还包括: 辅助技术,用来帮助用户克服它们的缺陷比如语音合成软件或者盲文显示器。 纯文本代理,例如Lynx。 支持Web的应用程序。 游戏控制台。 手机。 个人数字助理(PDA)。 交互式的电视机顶盒。 搜索引擎和其他索引程序 其他这么多类的用户代理(以及一些没有更新的旧用户代理),它们使用了不同的技术手段,对于JavaScript也是一个非常大的危险。并不是所有的访问者都能体验到你所应用的JavaScript增强,许多人都会出于安全的考虑关闭JavaScript。JavaScript既可

10、以用来做好事,也可以用来做坏事。如果操作系统(比如没有打补丁的windows)语序,可以通过JavaScript来在某台计算机上安装病毒或木马,或者读取用户信息并把它发送到另外一个服务器上。注解 没有办法知道访问者在使用什么工具,他的计算机功能如何。再者,你永远不知道访问者的经验和能力如何。这也是网络很好的一个方面每个人都可以参与。然而,这样会给JavaScript程序员带来意外的后果。在大多数情况下,你可能想要一种服务器端的替代方案。它可以测试用户代理是否支持所需要的功能,如果不支持,服务器会使用其替代方案。脚本语言的独立性对于网站是法律方面的要求,在英国的数字歧视法、美国法律的508条款和

11、世界上其他地区的法律中都有定义。这意味着如果你开发的站点没有JavaScript就不能使用,或者你的JavaScript增强需要用户或用户代理在不低效运行得情况下具有一定的能力,那么你的客户就可以控告你歧视。然而,JavaScript既不是邪恶的也不是没用的,它是一个优秀的工具,可以帮助在你平滑流畅的网站上冲浪的用户花费更少的时间。外文资料原文出自Beginning JavaScript with DOM Scripting and Ajax,2006:3-6 作者:Christian HeilmannBeginning JavaScript with DOM Scripting and Aj

12、axThe Why of JavaScriptIn the beginning of the Web, there was HTML and the Common Gateway Interface (CGI). HTML defines the parts of a text document and instructs the user agent (usually the web browser) how to show itfor example, text surrounded by the tags <p></p> becomes a paragraph.

13、Within that paragraph you may have <h1></h1> tags that define the main page heading. Notice that for most opening tags, there is a corresponding closing tag that begins with </. HTML has one disadvantageit has a fixed state. If you want to change something, or use data the visitor ent

14、ered, you need to make a round-trip to a server. Using a dynamic technology (such as ColdFusion, ASP, ASP.NET, PHP, or JSP) you send the information from forms, or from parameters, to a server, which then performs calculating/testing/database lookups, etc. The application server associated with thes

15、e technologies then writes an HTML document to show the results, and the resulting HTML document is returned to the browser for viewing. The problem with that is it means every time there is a change, the entire process must be repeated (and the page reloaded). This is cumbersome, slow, and not as i

16、mpressive as the new media “Internet” promised us to be. It is true that at least the Western world has the benefit of fast Internet connections these days, but displaying a page still means a reload, which could be a slow process that frequently fails (ever get an Error 404?).We need something slic

17、kersomething that allows web developers to give immediate feedback to the user and change HTML without reloading the page from the server. Just imagine a form that needs to be reloaded every time theres an error in one of its fieldsisnt it handier when something flags the errors immediately, without

18、 needing to reload the page from the web server? This is one example of what JavaScript can do for you.Some information, such as calculations and verifying the information on a form, may not need to come from the server. JavaScript is executed by the user agent (normally a browser) on the visitors c

19、omputer. We call this client-side code. This could result in fewer trips to the server and faster-running web sites.What Is JavaScript?JavaScript started life as LiveScript, but Netscape changed the namepossibly because of the excitement being generated by Javato JavaScript. The name is confusing th

20、ough, as there is no real connection between Java and JavaScriptalthough some of the syntax looks similar.Java is to JavaScript what Car is to CarpetFrom a JavaScript discussion group on UsenetNetscape created the JavaScript language in 1996 and included it in their Netscape Navigator (NN) 2.0 brows

21、er via an interpreter that read and executed the JavaScript added to .html pages. The language has steadily grown in popularity since then, and is now supported by the most popular browsers.The good news is that this means JavaScript can be used in web pages for all major modern browsers. The not-qu

22、ite-so-good news is that there are differences in the way the different browsers implement JavaScript, although the core JavaScript language is much the same. However, JavaScript can be turned off by the userand many companies and other institutions require their users to do so for security reasons.

23、 We will discuss this furthershortly, as well as throughout this book.The great thing about JavaScript is that once youve learned how to use it for browser programming, you can move on to use it in other areas. Microsofts serverIISuses JavaScript to program server-side web pages (ASP), PDF files now

24、 use JavaScript, and even Windows administration tasks can be automated with JavaScript code. A lot of applications such as Dreamweaver and Photoshop are scriptable with JavaScript. Operating system add-ons likethe Apple Dashboard or Konfabulator on Linux and Windows even allow you to write smallhel

25、per applications in JavaScript.Lately a lot of large companies also offer application programming interfaces (APIs) that feature JavaScript objects and methods you can use in your own pagesGoogle Maps being one of them. You can offer a zoomable and scrollable map in your web site with just a few lin

26、es of code.Even better is the fact that JavaScript is a lot easier to develop than higher programming languages or server-side scripting languages. It does not need any compilation like Java or C+, or to be run on a server or command line like Perl, PHP, or Ruby: all you need to write, execute, debu

27、g, and apply JavaScript is a text editor and a browserboth of which are supplied with any operating system. There are, of course, tools that make it a lot easier for you, examples being JavaScript debuggers like Mozilla Venkman, Microsoft Script Debugger, or kjscmd.Problems and Merits of JavaScriptA

28、s I mentioned at the outset of this chapter, JavaScript has been an integral part of web development over the last few years, but it has also been used wrongly. As a result, it has gotten a bad reputation. The reason for this is gratuitous JavaScript effects, like moving page elements and pop-up win

29、dows, which might have been impressive the first time you saw them but soon turned out to be just a “nice to have” and in some cases even a “nice to not have any longer.” A lot of this comes from the days of DHTML (more on this in Chapter 3).The term user agent and the lack of understanding what a u

30、ser agent is can also be a problem. Normally, the user agent is a browser like Microsoft Internet Explorer (MSIE), Netscape, Mozilla (Moz), Firefox (Fx), Opera, or Safari. However, browsers are not the only user agents on the Web. Others include Assistive technology that helps users to overcome the

31、limitations of a disabilitylike text-to-speech software or Braille displays Text-only agents like Lynx Web-enabled applications Game consoles Mobile/cell phones PDAs Interactive TV set-top boxes Search engines and other indexing programs And many moreThis large variety of user agents, of different t

32、echnical finesse (and old user agents that dont get updated), is also a great danger for JavaScript.Not all visitors to your web site will experience the JavaScript enhancements you applied to it. A lot of them will also have JavaScript turned offfor security reasons. JavaScript can be used for good and for evil. If the operating systemlike unpatched Windowsallows you to, you can install viruses or Trojan Horses on a computer via JavaScript or read out user information and send it to another server.Note There is no way of knowing what t

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论