欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript下兼容firefox選取textarea文本的代碼

 更新時間:2008年06月10日 20:21:17   作者:  
兼容firefox和ie的選取textarea文本的方法
主要用到的js代碼
復制代碼 代碼如下:

function getSelectedText(){
        var selectedText;
        var textField=document.getElementById('inputTextarea');
        if(window.getSelection) selectedText=getTextFieldSelection(textField);//getTextFieldSelection(document.getElementById("inputTextArea"));
        else selectedText=document.selection.createRange().text;
            alert(selectedText);
    }

    function getTextFieldSelection(e){
        //var oEvent=arguments.callee.caller.arguments[0];
        if(e.selectionStart != undefined && e.selectionEnd != undefined)
            return e.value.substring(e.selectionStart,e.selectionEnd);
        else return "";
    }


[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]

相關文章

最新評論