本帖最后由 helloword222 于 2010-04-19 15:39:22 编辑

解决方案 »

  1.   

    貌似在firefox下无法修改剪贴板上面的东西的!
      

  2.   

    估计不是,因为我将 onpaste 这个函数去掉之后,在 Firefox 里照样不能限制单引号的输入。<script>
        function renc(obj, reg, inputStr)
        {
            var docSel    = document.selection.createRange()
            if (docSel.parentElement().tagName != "INPUT")    return false
            oSel = docSel.duplicate()
            oSel.text = ""
            var srcRange    = obj.createTextRange()
            oSel.setEndPoint("StartToStart", srcRange)
            var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
            return reg.test(str)
        }
    </script>
    <input onkeypress ="return renc(this,/^[^']*$/,String.fromCharCode(event.keyCode))">
      

  3.   

    duplicate()这个函数是操作剪贴板的吗?
      

  4.   

    IE:document.selection   FireFox:window.getSelection()   document.selection只有IE支持,window.getSelection()也只有FireFox和   Safari支持,都不是标准语法。