好像不行吧 只能图片的url吧

解决方案 »

  1.   

    <body id="www.never-online.net">
        <script type="text/javascript">
        //<![CDATA[
        function copyEventHandler() {
          var x=document;
          var r=x.selection.createRange();
          x.execCommand("Copy");
        }
        //]]>
        </script>
        选中图片,点COPY
        <input onclick="copyEventHandler()" type="button" value="COPY"/>
        <img src="http://zi.csdn.net/760-90netbeans-video_2.gif"/>
      </body>
      

  2.   

    上面的方法复制下来的只是图片的url,若想获得图片,就得用流来读取文件.
      

  3.   

    楼上,你先试试再说,看看是图片,还是URL,COPY后paste到你的word..:D
      

  4.   

    BlueDestiny 的方法试过了也不行, 如果要实现复制图片到剪切板那么复制的其实应该是IE临时文件夹里面的图片文件,可是由于安全限制JS又无法操作本地文件,这似乎真的是无法完成的任务
      

  5.   

    execCommand->>MS IE ONLY
      

  6.   

    怎么会没有效果??看下面...
    <body id="www.never-online.net">
        <script type="text/javascript">
        //&lt;![CDATA[
        onload = function () {  
          var x;
          x=document.getElementById("p").contentWindow.document
          x.open();
          x.write("<body contentEditable=true>");
          x.close();
          window.clipboardData.clearData();
        }
        function copyEventHandler() {
          var x=document;
          var r=x.selection.createRange();
          x.execCommand("Copy");
          x=document.getElementById("p").contentWindow.document;
          x.selection.createRange();x.body.focus();
          x.execCommand("Paste");
        }
        //]]&gt;
        </script>    <img src="http://zi.csdn.net/760-90netbeans-video_2.gif"/><br/>
            选中图片,点COPY<br/>
        <input onclick="copyEventHandler()" type="button" value="COPY"/>    下面的iframe是Paste后的效果<br/>
        <iframe id="p"></iframe>
      </body>
      

  7.   

    TO BlueDestiny 我想这复制的只是选中的HTML代码吧?
    我需要达到的是复制图片,然后可以把图片粘贴到画图工具里面去的
      

  8.   

    可以实现,不过只有IE有效。看下面代码:
    html:<img src="xxxxx/null.gif" width="0" height="0" id="10008">
    <div class="padding5"><input type="button" class="ctrlc" value="复制到QQ" alt="10008"></div>
    js: var $copy = document.body.createControlRange();
    $(".ctrlc").click(function(){
    //var $img = new Image();
    var $id = $(this).attr("alt");
    var $src = $(".picture").attr("src");
    $("#" + $id).attr("src",$src); var $this = document.getElementById($(this).attr("alt"));    if ($this.tagName != 'IMG')
    return; if (typeof $this.contentEditable == "undefined")
    return; if (!document.body.createControlRange)
    return;    $this.contentEditable = true;
        $copy.addElement($this);
        $copy.execCommand("Copy");
        $this.contentEditable = false;
        alert("复制完成,请在QQ聊天对话框里按Ctrl+V(或点右键后在出现的菜单中点粘贴)然后发图!");});