<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

    NOTE: I’ve released a set of JavaScript Quicktags (that implement this technique) under the LGPL license. Please look at this code as it has a variety of enhancements and bug fixes.

    I discovered a real JavaScript gem in PHPMyAdmin this morning. They have code that inserts content into a <textarea> at the cursor position instead of just at the beginning/end of the content. This is something I thought wasn’t possible – I’m quite pleased I was wrong.

    I’ll be glad to see this code spread quickly to web forms that use buttons to aid in styling text and inserting image and link tags. WordPress and other blog and web forum packages would really benefit from this. (PHPMyAdmin is GPL, so any other GPL app should be able to use their code directly with attribution).

    Here is a quick look at a generic version of the technique:

    function insertAtCursor(myField, myValue) {
    //IE support
    if (document.selection) {
    myField.focus();
    sel = document.selection.createRange();
    sel.text = myValue;
    }
    //MOZILLA/NETSCAPE support
    else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos)
    + myValue
    + myField.value.substring(endPos, myField.value.length);
    } else {
    myField.value += myValue;
    }
    }
    // calling the function
    insertAtCursor(document.formName.fieldName, 'this value');
    I guess when the mouse leaves the textarea, it still has a cursor position left over. This code uses that position just as you’d want it to.
    posted on 2010-06-04 03:12 seal 閱讀(230) 評論(0)  編輯  收藏 所屬分類: Javascript
    主站蜘蛛池模板: 国产精品亚洲一区二区三区久久 | 亚洲AV无码AV男人的天堂| 曰批全过程免费视频网址| 亚洲精品欧美综合四区| 亚洲成a人片7777| 久久精品国产亚洲AV麻豆不卡| 在线免费观看色片| 91热成人精品国产免费| 国偷自产一区二区免费视频| 久久精品国产亚洲AV未满十八 | 一级毛片aaaaaa免费看| 久久国产免费直播| 国产精品玖玖美女张开腿让男人桶爽免费看| 亚洲伊人久久大香线蕉影院| 亚洲区小说区图片区QVOD| 亚洲AV伊人久久青青草原| 四虎影视永久免费观看网址| 天天摸天天碰成人免费视频| 色妞WWW精品免费视频| 曰批全过程免费视频在线观看| 无码国产精品一区二区免费式影视| 国产成人精品免费久久久久| 午夜视频免费在线观看| 97性无码区免费| 永久免费无码网站在线观看| 日本特黄a级高清免费大片| 高清在线亚洲精品国产二区| 亚洲精品国产日韩无码AV永久免费网 | 久久久久久亚洲Av无码精品专口| 亚洲视频日韩视频| 亚洲精品国产精品| 四虎影视无码永久免费| 1000部拍拍拍18勿入免费凤凰福利| 美女视频黄的全免费视频网站| 国产猛烈高潮尖叫视频免费| 亚洲国产精品一区二区第一页| 91大神亚洲影视在线| 特级毛片全部免费播放| 国产免费女女脚奴视频网| 免费人成视网站在线观看不卡| 亚洲av无码av制服另类专区|