<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 閱讀(237) 評論(0)  編輯  收藏 所屬分類: Javascript
    主站蜘蛛池模板: 亚洲成av人片在线观看天堂无码| A级毛片内射免费视频| 国产亚洲精品资在线| 一级毛片免费在线观看网站| 国产99视频精品免费视频7| 亚洲国产成人综合精品| 香蕉高清免费永久在线视频 | 久久99精品免费视频| 亚洲国产精品国自产拍AV| 久久久99精品免费观看| 亚洲最大黄色网址| 女人被男人躁的女爽免费视频| 香蕉大伊亚洲人在线观看| 永久免费毛片手机版在线看| 亚洲AV成人精品日韩一区| 内射无码专区久久亚洲| 在线日本高清免费不卡| 亚洲欧洲精品久久| 最近中文字幕mv免费高清视频7| 亚洲天然素人无码专区| 国产人成免费视频| 久久一区二区免费播放| 久久亚洲熟女cc98cm| 女性无套免费网站在线看| 一级做a爰全过程免费视频毛片| 亚洲AV无码精品无码麻豆| 久久久久久免费视频| 黑人粗长大战亚洲女2021国产精品成人免费视频| 日韩精品视频免费在线观看| 亚州**色毛片免费观看| 亚洲福利视频一区| 性色av免费观看| 成全视成人免费观看在线看| 亚洲美女大bbbbbbbbb| 国产小视频免费观看| 免费人成毛片动漫在线播放| 国产成人精品日本亚洲18图| 国产成人精品亚洲精品| 国产卡一卡二卡三免费入口| 无码毛片一区二区三区视频免费播放| 亚洲AV无码国产精品色午友在线|