<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
    主站蜘蛛池模板: 成人免费无码大片a毛片软件| 视频免费在线观看| 丁香花在线观看免费观看| 亚洲精品人成电影网| 在线美女免费观看网站h| 亚洲第一中文字幕| 69视频在线是免费观看| 亚洲综合在线成人一区| 亚洲一级毛片免费看| 亚洲国产精品综合久久20| 免费无码又爽又刺激高潮| 精品亚洲成a人在线观看| 又大又硬又爽免费视频| 美女无遮挡拍拍拍免费视频| 亚洲精品乱码久久久久久自慰| 99麻豆久久久国产精品免费 | 一个人看的www免费视频在线观看| 亚洲AV中文无码字幕色三| 久久久久免费精品国产小说| 亚洲小说图片视频| 全免费一级午夜毛片| 人成免费在线视频| 久久精品国产亚洲| 四虎永久在线观看免费网站网址| 亚洲一区二区三区高清在线观看| 国产一区在线观看免费| 最近免费中文字幕MV在线视频3| 亚洲精品在线网站| 日韩免费高清一级毛片在线| 免费无码午夜福利片69| 亚洲日本在线观看| 在线观看人成视频免费| 久久久久国色AV免费观看| 亚洲系列国产精品制服丝袜第| 毛片免费在线播放| 久久国产乱子伦精品免费午夜| 91精品国产亚洲爽啪在线影院| 国产乱子影视频上线免费观看| 国产在线国偷精品免费看| 亚洲a∨无码男人的天堂| 国产AV无码专区亚洲AV漫画 |