《外文翻译--使用JavaScript设计网页》-公开DOC·毕业论文

上传人:zhuma****mei2 文档编号:137044857 上传时间:2020-07-04 格式:DOC 页数:13 大小:116KB
返回 下载 相关 举报
《外文翻译--使用JavaScript设计网页》-公开DOC·毕业论文_第1页
第1页 / 共13页
《外文翻译--使用JavaScript设计网页》-公开DOC·毕业论文_第2页
第2页 / 共13页
《外文翻译--使用JavaScript设计网页》-公开DOC·毕业论文_第3页
第3页 / 共13页
《外文翻译--使用JavaScript设计网页》-公开DOC·毕业论文_第4页
第4页 / 共13页
《外文翻译--使用JavaScript设计网页》-公开DOC·毕业论文_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《《外文翻译--使用JavaScript设计网页》-公开DOC·毕业论文》由会员分享,可在线阅读,更多相关《《外文翻译--使用JavaScript设计网页》-公开DOC·毕业论文(13页珍藏版)》请在金锄头文库上搜索。

1、大连交通大学2013届本科生毕业设计(论文)外文翻译外文原文 Source: Web Page Design Using JavaScriptTHE BASICS JAVASCRIPT uses a subset of the programming language JAVA to provide a high level of interactivity on a web page. JavaScripts are stored within an HTML document and are interpreted by the web browser. JavaScripts may b

2、e located within the HTML code at the point in the page where they are to appear on the screen or they may be written using functions. Functions are small subprograms that are stored between the head tags of an HTML document and are called on to be executed when a particular event occurs. Whether th

3、e script is stored between the head tags or within the body of the HTML document, it must be enclosed in script tags. Also, a set of HTML comment tags are typically used inside the script tags so that older browsers that do not support JavaScript will ignore the script and continue to process the pa

4、ge without errors. Following is an example of the script and comment tags: Be aware that JavaScript is case sensitive.the difference between a working script and an error message can be one capital letter. ALERT BOXES To pop up an alert box include the following line of code inside of script tags in

5、 the body of your HTML document. Please note that the processing of the page will stop until the viewer responds to the alert box. alert (Place the text to be displayed in the alert box between these quotes.) Other types of pre-made dialog boxes are available such as the prompt and confirm boxes. In

6、 order to take full advantage of the features of these dialog boxes you must write more JavaScript code which can use the values that are returned by the dialog boxes. The following statements will pop up a dialog box that requires a yes or no answer (OK or Cancel). If the answer is OK then the vari

7、able named answer has a value of true and if the answer is Cancel then the variable named answer has a value of false. You can then use an if statement in the JavaScript code to respond appropriately. var answer = confirm (Are you sure you want to quit?)if (answer=true) window.close()The following c

8、ode will pop up a dialog box that asks the user to enter some sort of information. If the user clicks OK the information they entered is stored in the variable. The second set of quotation marks inside of the prompt statement make the contents of the text box blank when the dialog box is displayed.

9、var response = prompt (What is your name? ,)document.write (Hello + response + !) Notice that in the last two examples the window and document objects were used. Window refers to the browser window and document refers to the page being displayed. The use of a dot after the name of the object allows

10、actions to be performed on that object or properties of that object to be modified. In this next example, the navigator object is referenced in order to display the browser name and version. alert (You are using + navigator.appName + version + navigator.appVersion + .) POP-UP WINDOWSAn additional br

11、owser window may be opened using a simple JavaScript. The open method contains three parts as in the following example: the name of the document or url of the web site to be displayed in the new window, the name that may be used to refer to the browser window (requires more code than is shown here),

12、 and the properties of the new window. Please note that the properties are all listed in one set of quotation marks and are separated by commas.open (myfile.html, mywin, height=200, width=200, titlebar=false) The following properties may be used to control the appearance of the new window: Table1-1

13、properties may be used to control the appearance of the new windowFeatureExampleDescriptionheight height = 200 determines the height of the new window in pixels width width=200 determines the width of the new window in pixels titlebar titlebar=false removes the title bar from the new window location

14、 location includes the url / address text box in the new window menubar menubar includes a menu bar in the new window resize resize=off makes the new window a fixed size scrollbars scrollbars adds scrollbars to the new window status status includes a status bar for the new window toolbar toolbar=yes

15、 adds a toolbar for the new window WRITING FUNCTIONSFunctions are small subprograms that are located within script tags between the head tags of an HTML document. Functions are executed when they are called by name from an event handler within the body of an HTML document. The basic structure of a function is as follows: function NameOfFunction( )Include JavaScript Code Here EVENT HANDLERSThe following example demonstrates the use of event handler onclick as well as the u

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 毕业论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号