<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 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      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 閱讀(237) 評論(0)  編輯  收藏 所屬分類: Javascript
    主站蜘蛛池模板: 亚洲黄色在线网站| 亚洲伊人久久精品影院| 无码av免费毛片一区二区| 69xx免费观看视频| 国产网站免费观看| 久久久久亚洲av成人无码电影| 久久亚洲精品中文字幕| 风间由美在线亚洲一区| 成人免费一区二区三区| 99视频在线精品免费| 日本一道一区二区免费看| 亚洲综合自拍成人| 最近免费中文字幕大全免费版视频| 四虎永久在线精品免费影视| 亚洲精品国产肉丝袜久久| 色老头综合免费视频| 永久免费的网站在线观看| 亚洲精品一级无码鲁丝片| 亚洲最大黄色网址| 成在人线av无码免费高潮水| 亚洲av永久无码精品秋霞电影影院| 国产精品久久亚洲一区二区| 十八禁在线观看视频播放免费| 日韩中文字幕免费| 无人视频在线观看免费播放影院| 日本XXX黄区免费看| 亚洲人成色777777精品| 2020因为爱你带字幕免费观看全集 | 精品亚洲A∨无码一区二区三区| 久久国产精品成人片免费| 久久精品国产亚洲AV久| 国产精品99久久免费观看| 免费a级毛片18以上观看精品| 亚洲女人初试黑人巨高清| 超pen个人视频国产免费观看| 久久av无码专区亚洲av桃花岛| 成年女人18级毛片毛片免费| 77777_亚洲午夜久久多人| 成年女人毛片免费播放人| jizz免费观看| 国产成人精品亚洲精品|