【正文】
表單可用于當(dāng)按鈕按下時(shí)執(zhí)行各種操作。s!) (Only + (numdays) + days until NewYear39。Ceil是ceiling的縮寫(xiě),意味著該數(shù)將四舍五入到最近的整數(shù)。做除法,將會(huì)轉(zhuǎn)變?yōu)閺慕裉斓侥繕?biāo)日期的天數(shù)。上面例子中的變量then實(shí)際上保存的是從計(jì)算機(jī)開(kāi)始計(jì)數(shù)到在2002年1月1日要經(jīng)過(guò)的毫秒數(shù)。如果是到新年的倒計(jì)時(shí),聲明如下。One of them will need to be set to the date that you are targeting with your countdown. The declarations would look as follows if you were going to count down to New Year39。( )+:+( )+:+( )= function myclock( ){如果是單等號(hào),則實(shí)際上使條件恒成立,1月將始終顯示。Examine the following 。表13 Date類型變量中的不同部分及其描述函數(shù)調(diào)用描述( ) 返回0到6之間的數(shù)來(lái)表明星期幾(星期日是0,星期一是1,以此類推) ( ) 返回0到11之間的數(shù)字來(lái)表明月份 (一月是0,二月是1,以此類推) ( ) 返回月中的一天 (1 31) ( ) 返回四位年份( ) 返回小時(shí)(0 23) ( ) 返回分鐘(0 59) ( ) 返回秒 (0 59) One way to convert the numbers for the month and day of week in to words is to use if if 語(yǔ)句。Assuming that now is the variable declared of type Date the following table describes how to access the parts of the date and , 現(xiàn)在已經(jīng)聲明了一個(gè)Date類型的變量,下表描述了如何訪問(wèn)時(shí)間和日期的不同部分。下面一行腳本標(biāo)簽用于To display the date and time of the last update (the last time the document was saved) use the following one line inside of script tags:顯示最后一次更新(文件最后一次保存)的日期和時(shí)間: (This page last updated + ) (This page last updated + )To display the current time and date on a web page you must declare a variable of type Date ( var now = new Date ). The variable can then be used to access various parts of the date and time including day of the week, month, day of the month, year, hours (in military time), minutes, and ,必須聲明一個(gè)Date類型的變量( var now = new Date )。Displaying the date and time of the last update is a good practice to get in to for all of your pages because frequent updates are one sign of a quality ,因?yàn)轭l繁更新是網(wǎng)站質(zhì)量的標(biāo)志。 (position, ) +var message = This is a test... The following function will generate a scrolling message in a text box named mymessagebox which is part of a form named 。 SCROLLING TEXT滾動(dòng)文字 由于只有IE瀏覽器支持字幕標(biāo)簽,所以應(yīng)該盡量避免使用它,而利用一個(gè)JavaScript來(lái)產(chǎn)生滾動(dòng)文字。 onmouseout=src=39。When the desired event occurs (onmouseover, onmouseout) change the source of the graphic as in the example that follows:當(dāng)事件發(fā)生(如onmouseover,onmouseout)改變的圖形的源,如例子所示: img src= onmouseover=src=39。作為鼠標(biāo)懸停的結(jié)果,任何應(yīng)用于特定對(duì)象的樣式屬性都可以被改變。 MOUSEOVERS 鼠標(biāo)懸停A mouseover refers to the effect that occurs when the properties of an object are changed if the mouse is positioned over the top of the object and then again if the mouse is removed from the object. 鼠標(biāo)懸停,是指當(dāng)鼠標(biāo)位于一個(gè)對(duì)象上,然后又離開(kāi)對(duì)象區(qū)域時(shí),對(duì)對(duì)象屬性產(chǎn)生的影響。To display more that one item at a time (and create a text box with a vertical scrollbar) include the size attribute in the select (建立一個(gè)有垂直滾動(dòng)條的文本框),在選擇標(biāo)簽中包含尺寸參數(shù)。For example, if the form is named myform, the select tag is named mychoices, and the value of each option is a url then the statement = will take you to the new page that was selected from the drop down ,如果窗體被命名為myform,每個(gè)選項(xiàng)的值是一個(gè)URL, = 。在鉆則標(biāo)簽中設(shè)置選項(xiàng)的值,指示要顯示新的一頁(yè)的URL。通常只寫(xiě)一個(gè)函數(shù),除非要求一個(gè)以上事情發(fā)生。39。 bordercolor : red}/style/headbodyform name=myforminput type=button name=mybutton id=bigbutton value=CLICK ME! height : 50px。 fontfamily : arial。Copy and paste this entire set of code in to a new document and test it ,并測(cè)試它。 The basic structure of a function is as follows: 該函數(shù)的基本結(jié)構(gòu)如下:function NameOfFunction( ){JavaScript代碼}function NameOfFunction( ){Include JavaScript Code Here}EVENT HANDLERS事件處理程序 The following example demonstrates the use of event handler onclick as well as the use of styles to control the appearance of ,以及使用樣式來(lái)控制按鈕的外觀。open (, mywin, height=200, width=200, titlebar=false)open (, mywin, height=200, width=200, titlebar=false) The following properties may be used to control the appearance of the new window:下列屬性可用于控制新窗口的外觀: 表11 可用于控制新窗口外觀的屬性特征例子描述height height = 200 決定了新窗口的高度,單位是像素width width=200 決定了新窗口的寬度,單位是像素titlebar titlebar=false 移除新窗口的標(biāo)題條location location 給新窗口添加URL/地址條menubar menubar 給新窗口添加菜單條resize resize=off 使新窗口大小可變scrollbars scrollbars 給新窗口添加滾動(dòng)條status status 給新窗口添加狀態(tài)條toolbar toolbar=yes 給新窗口添加工具條WRITING FUNCTIONS編寫(xiě)函數(shù)Functions are small subprograms that are located within script tags between the head tags of an HTML ,存儲(chǔ)于HTML文件的頭標(biāo)簽之間。例如在下面的例子中打開(kāi)方法分為三部分:在新打開(kāi)窗口中要顯示的文件名稱或網(wǎng)站的URL,可能用到的支出瀏覽器窗口的名字(所需實(shí)際代碼比我們這里展示的要多),以及新窗口的屬性。 alert (You are using + + version + The use of a dot after the name of the object allows actions to be performed on that object or properties of that object to be ,后面可以是對(duì)象的動(dòng)作或者是對(duì)象可以被改變的屬性。 var response = prompt (What is your name? ,) (font size=7 color=red face=arialHello + response + !) var response = prompt (What is your name? ,) (font size=7 color=red face=arialHello + response + !)Notice that in the last two examples the window and document objects were ,最后兩個(gè)例子中使用了窗口和文檔對(duì)象。If the user clicks OK the information they entered is stored in the 。You can then use an if statement in the JavaScript code to respond ,您可以使用JavaScript代碼語(yǔ)句作出適當(dāng)響應(yīng)。The following statements will pop up a dialog box that requires a yes or no answer (OK or Cancel).下面的語(yǔ)句會(huì)彈出一個(gè)對(duì)話框,需要回答是或否(確定或取消)。 alert (Place the text to be displayed in the alert box between these quotes.)alert (將要顯示在警告框中的文本寫(xiě)在引號(hào)之間)Other types of premade dialog boxes are available