1.知道图片Url地址。比如http://123.com/a.jpg;
如果通过js复制图片到剪贴板。
2.要复制图片,不是图片的url。
谢谢

解决方案 »

  1.   

    1.知道图片Url地址。比如http://123.com/a.jpg;
    如何通过js复制图片到剪贴板。
    2.要复制图片,不是图片的url。
    3.粘贴的时候是图片。
      

  2.   

    这个好像没办法的吧FF这些连文字都没办法复制IE还能复制文字。。图片就不知道了。。
      

  3.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head>
    <SCRIPT LANGUAGE="JScript">
     var oPopup = window.createPopup();
     function ButtonClick(img)
     {
     img.contentEditable = 'true';
     var controlRange;
     if (document.body.createControlRange) {
     controlRange = document.body.createControlRange();
     controlRange.addElement(img);
     controlRange.execCommand('Copy');
     alert('复制成功');
     }
     img.contentEditable = 'false';
     }
     </SCRIPT>
     <body>
     <img id="divId" src="111.jpg"  onclick="ButtonClick(this)" />
     </body>
    </html>csdn的老帖子,纯搬运。图片地址自己换。
      

  4.   

    回复:mabao669;
    只知道img url;没有实际的显示图片<img id="divId" src="111.jpg"  onclick="ButtonClick(this)" />,所以上述的内容并不适合
      

  5.   

    function copyToClipBorad(url) {
        var oImg = document.createElement('img');
        oImg.contentEditable = true;
        oImg.src = url;
        if(document.body.createControlRange)
        {
        var ControlRange = document.body.createControlRange();
        ControlRange.addElement(oImg);
        ControlRange.execCommand('Copy');
        } 
        oImg.contentEditable = false; 
    }
    为什么这段代码提示ControlRange.addElement(oImg)错误???
      

  6.   

    在你的代码上加了一句
    var oImg = document.createElement('img');
    oImg.contentEditable = true;
    oImg.src = url;
    document.body.appendChild(img);
    至于为什么要加这么一句,请在代码中找原因吧。
    另:document.body.appendChild(img);这行代码会在网页中显示出你新创建的图片。
    如果不想要该图片在页面上显示:img.style.display="none"
    这些自己多琢磨吧
      

  7.   

    感谢mabao669,分少了点,下次补你,谢谢!