最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JavaScript初級教程(第五課)第2/4頁

 更新時間:2007年04月05日 00:00:00   作者:  

    文字域可以鏈接onBlur、onFocus和onChange事件。當有人點擊文字域的里邊時則發(fā)生onFocus事件。而如果點擊文字域的外面或按了tab鍵時則發(fā)生onblur事件。如果有人改變了文字域內(nèi)的內(nèi)容然后轉(zhuǎn)到文字域外部的區(qū)域時則發(fā)生onChange事件。

    試著做這些事情看下面的文字域會發(fā)生什么情況。

   

   

    以下是編制方法:文字域的編碼:

    <input type="text" name="first_text" onFocus="writeIt('focus');" onBlur="writeIt('blur');" onChange="writeIt('change');">

    每一個事件處理器調(diào)用函數(shù)writeIt(),該函數(shù)已作了定義。編碼如下:

    <script language="JavaScript">
    <!-- hide me
        function writeIt(the_word)
        {
            var word_with_return = the_word + "\n";
            window.document.first_form.the_textarea.value += word_with_return;
        }
    // show me -->
    </script>

    前幾行是典型的JavaScript預(yù)定義。主體中的第1行

    var word_with_return = the_word + "\n";

    將一個變量word_with_return進行初始化為函數(shù)處理后的字符串并加上換行符"\n".。注意"\n" 是標準的計算機指令。

    下一行

    window.document.first_form.the_textarea.value += word_with_return;

    將文字區(qū)域的值設(shè)置為其原值加新變量。其作用相當于

    window.document.first_form.the_textarea.value = window.document.first_form.the_textarea.value + word_with_return;

    目前我們已經(jīng)學(xué)習(xí)了文字域和文字區(qū)域(值)的屬性,接下來我們學(xué)習(xí)文字域和文字區(qū)域處理所用的方法:blur()、focus()和select()。

    下面的鏈接顯示了focus() 和select()如何工作。注意他們工作一次后可能會終止功能。

   

    Mouseover to focus Mouseover to select

    以下為表單和鏈接的編碼:

    <form name="method_form">
        <input type="text" name="method_text" size=40 value="Hey, hey, we're the monkeys">
    </form>

    <a href="#" onMouseOver="window.document.method_form.method_text.focus();">Mouseover to focus</a>
    <a href="#" onMouseOver="window.document.method_form.method_text.select();">Mouseover to select</a>

    其使用方法和調(diào)用任何對象方法的做法是一樣的:object_name.method(). 該文字域的名稱是window.document.form_name.text_field_name,所以用下列語句就可調(diào)用文字域的focus()方法。 

    window.document.method_form.method_text.focus();

相關(guān)文章

最新評論

垦利县| 西林县| 澳门| 会东县| 都江堰市| 兴安县| 峨边| 吴忠市| 邻水| 景谷| 和林格尔县| 新竹县| 镇江市| 偏关县| 彰化市| 灵山县| 尚义县| 贵阳市| 旌德县| 江山市| 叶城县| 温州市| 石河子市| 永寿县| 邵武市| 泽普县| 巴林左旗| 元谋县| 密云县| 固阳县| 阳西县| 石阡县| 化隆| 昆山市| 津市市| 吴江市| 兴化市| 义马市| 余干县| 澎湖县| 永仁县|