<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
    主站蜘蛛池模板: 亚洲av产在线精品亚洲第一站| 日韩免费无码一区二区三区| 亚洲性69影院在线观看| 免费在线不卡视频| 国产精品久久久久久久久免费| 香蕉免费一级视频在线观看| 亚洲人成色99999在线观看| 水蜜桃亚洲一二三四在线| 亚洲免费一区二区| 国产又黄又爽又刺激的免费网址 | 精品一区二区三区免费观看| 亚洲国产欧美国产综合一区| 亚洲视频一区在线| 亚洲成AV人片在线观看ww| 亚洲天堂中文字幕在线| 国产精品免费视频网站| 欧美最猛性xxxxx免费| 84pao强力永久免费高清| 中文精品人人永久免费| 特黄特色的大片观看免费视频| 亚洲欧美国产日韩av野草社区| 亚洲伊人久久大香线焦| 亚洲欧洲日本天天堂在线观看| 久久精品国产亚洲| 亚洲电影一区二区| 亚洲国产精品一区二区成人片国内 | 久久综合AV免费观看| 国产91免费在线观看| 91精品导航在线网址免费| 成人电影在线免费观看| 野花香在线视频免费观看大全| 精品国产污污免费网站入口| 国产免费区在线观看十分钟 | 四虎永久在线精品免费影视| 日本a级片免费看| 国产猛烈高潮尖叫视频免费| 国产午夜无码视频免费网站| 四虎影视精品永久免费网站| 亚洲v国产v天堂a无码久久| 亚洲第一页日韩专区| 亚洲情侣偷拍精品|