【正文】
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. 鼠標懸停,是指當鼠標位于一個對象上,然后又離開對象區(qū)域時,對對象屬性產(chǎn)生的影響。產(chǎn)生鼠標懸停最快捷的方法就是利用onmouseover和onmouseout 事件處理程序。作為鼠標懸停的結果,任何應用于特定對象的樣式屬性都可以被改變。The quickest way to generate a mouseover is to use the onmouseover and onmouseout event handlers in a form of inline the style section of the DHTML page of this web site to see an example of mouseovers used with text as an inline style.Performing mouseovers with a graphic is not much different than with text. 在圖形上實現(xiàn)鼠標懸停與文本沒有太大區(qū)別。When the desired event occurs (onmouseover, onmouseout) change the source of the graphic as in the example that follows:當事件發(fā)生(如onmouseover,onmouseout)改變的圖形的源,如例子所示: img src= onmouseover=src=39。39。 onmouseout=src=39。39。 SCROLLING TEXT滾動文字 由于只有IE瀏覽器支持字幕標簽,所以應該盡量避免使用它,而利用一個JavaScript來產(chǎn)生滾動文字。Since the marquee tag is only supported by Internet Explorer it is a good idea to avoid it as much as possible and use a JavaScript to generate scrolling text this JavaScript it is also quite easy to place the scrolling text on the status bar instead of in the document itself by using as the destination for the 。The following function will generate a scrolling message in a text box named mymessagebox which is part of a form named 。當頁面載入是,onlord事件處理程序也必須在體標簽中被使用來調用函數(shù)。var message = This is a test... var position = 0function mymessage( ){ = (position, ) + (0, position) position = position + 1 if (position ) { position = 0 } (mymessage( ), 300)}DATES AND TIMES日期和時間 Dates and times are often displayed on web pages to indicate when a page was last updated, when a page was loaded, or to display a countdown to a particular ,往往顯示在網(wǎng)頁顯示中,用于表明頁面的最后更新時間,加載時間,或顯示特定事的倒計時。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 ,因為頻繁更新是網(wǎng)站質量的標志。The date/time stamp lets the viewer know how recent the information is and therefore provides one indication of ,因此表明了其有效性。下面一行腳本標簽用于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:顯示最后一次更新(文件最后一次保存)的日期和時間: (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 ,必須聲明一個Date類型的變量( var now = new Date )。然后這個變量可以被用來訪問日期和時間的各個部分,包括星期幾,日,月,年,小時,分鐘和秒。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)聲明了一個Date類型的變量,下表描述了如何訪問時間和日期的不同部分。Each of the function calls may be used in a statement to display the 。表13 Date類型變量中的不同部分及其描述函數(shù)調用描述( ) 返回0到6之間的數(shù)來表明星期幾(星期日是0,星期一是1,以此類推) ( ) 返回0到11之間的數(shù)字來表明月份 (一月是0,二月是1,以此類推) ( ) 返回月中的一天 (1 31) ( ) 返回四位年份( ) 返回小時(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 語句。Using a lot of if statements is not the most efficient way to display the words, but it is the method that requires the least amount of programming ,并不是最有效的防范,但它卻是需要編程知識最少的方法。Examine the following 。Notice the condition that follows the word if is in parentheses and that a double equal sign is used for the parison. A single equal sign will actually make the condition true no matter what so January would always be ,并且雙等號用于比較。如果是單等號,則實際上使條件恒成立,1月將始終顯示。 if (( ) == 0) (January) The following function would display a working clock if your page contained a form called myform which contained a text box named mybox and the function was called using the onload event handler in the body ,如果您的頁面中包含一個名為為myform的窗體,其中有文本框名mybox,然后在體標簽中使用onload事件處理程序調用函數(shù)。 function myclock( ){var now = new Date=( )+:+( )+:+( ) (myclock( ),1000)}To display a countdown to a future date, you will need two variables of type new ,則需要兩個Date類型的變量。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。s 。如果是到新年的倒計時,聲明如下。 var now = new Datevar now = new Datevar then = new Date(January 1, 2002) The variable now in the above example actually holds the number of milliseconds that have passed since the puter started counting until 。上面例子中的變量then實際上保存的是從計算機開始計數(shù)到在2002年1月1日要經(jīng)過的毫秒數(shù)。By subracting the two amounts and storing the answer in a new variable you will know the number of milliseconds between now and your target ,并保存在一個新的變量里,將會得到當前到目標日期之間的毫秒數(shù)。做除法,將會轉變?yōu)閺慕裉斓侥繕巳掌诘奶鞌?shù)。為了顯示整數(shù)結果,如下面例子所示,用變量numdays保存要顯示的天數(shù)。Ceil是ceiling的縮寫,意味著該數(shù)將四舍五入到最近的整數(shù)。(Only + (numdays) + days until New Year39。s!) (Only + (numdays) + days until NewYear39。s!)INTERACTIVE FORMS交互式表單表單的用途有很多,遠不止是通過電子郵件提交信息。表單可用于當按鈕按下時執(zhí)行各種操作。13