<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 閱讀(230) 評論(0)  編輯  收藏 所屬分類: Javascript
    主站蜘蛛池模板: 久久精品夜色噜噜亚洲A∨| 亚洲成在人线在线播放无码| 91禁漫免费进入| 亚洲精品美女久久久久久久| 亚洲日韩在线观看| h在线观看视频免费网站| 久久亚洲精品高潮综合色a片| 精品亚洲永久免费精品| 西西大胆无码视频免费| 一级毛片视频免费| 亚洲一卡2卡4卡5卡6卡在线99 | 久久免费线看线看| 中文字幕亚洲综合久久综合| 亚洲中文字幕无码中文字在线| 国产1000部成人免费视频| 久久精品亚洲视频| 久久亚洲免费视频| 亚洲伦理一区二区| 日韩精品成人亚洲专区| 久久WWW免费人成一看片| 人禽伦免费交视频播放| 亚洲H在线播放在线观看H| 亚洲深深色噜噜狠狠爱网站| 午夜免费福利在线| 中文字幕免费在线观看| 久久性生大片免费观看性| 久久精品国产69国产精品亚洲| 男女交性永久免费视频播放| **实干一级毛片aa免费| 一个人看的免费视频www在线高清动漫| 亚洲宅男精品一区在线观看| 亚洲成色WWW久久网站| 亚洲av再在线观看| 美女无遮挡拍拍拍免费视频| 亚洲欧美国产国产综合一区| 99久久精品国产亚洲| 亚洲精品国偷自产在线| 亚洲视频在线精品| 免费看国产一级片| 午夜爱爱免费视频| 久久国内免费视频|