function selImg(text){
document.frames["SendMsg"].focus();
var range =document.frames["SendMsg"].document.selection.createRange();
alert(range);   ==>这样在Chrome浏览器里不行,应该怎么修改才对啊?
}

解决方案 »

  1.   

    你看看报什么错 类似什么跨域之类的话 部署到真的web服务器上应该可以了
      

  2.   

    chrome 不支持 document.selection.
    要用window.getSelection ()
    <head>
        <script type="text/javascript">
            function TestSelection () {
                if (window.getSelection) {  // all browsers, except IE before version 9
                    var selectionRange = window.getSelection ();                                        
                    alert ("The text content of the selection:\n" + selectionRange.toString ());
                } 
                else {
                    if (document.selection.type == 'None') {
                        alert ("No content is selected, or the selected content is not available!");
                    }
                    else {
                        var textRange = document.selection.createRange ();
                        alert ("The text content of the selection:\n" + textRange.text);
                    }
                }
            }
        </script>
    </head>
    <body>
        Select some text or <button>element</button>, or do not select anything, before you click on the button below.
        <br /><br />
        <button onclick="TestSelection ();">Test the selection!</button>
    </body>
      

  3.   

    rayaspnet
    是不是我的这行代码
    var range =document.frames["SendMsg"].document.selection.createRange();
    要改成
    var range =document.frames["SendMsg"].window.getSelection ();