2017-01-01 89 views
0

为什么我的网站在我的手机上工作,但不是在我的电脑上我试过所有的IE浏览器firefox和我似乎无法下载图像从div但是当我用我的手机它工作正常(只有丁当)。发生什么事?这里是我的网站https://torcdesign.com/mom有人可以帮助我找到一个解决方案,它在工作的所有浏览器网站在一些浏览器但不是全部

var download = document.getElementById("download"), 
 
\t \t result = document.getElementById("result"); 
 

 
function renderContent() { 
 
    html2canvas(document.getElementById("content"), { 
 
     allowTaint: true 
 
    }).then(function(canvas) { 
 
    \t \t result.appendChild(canvas); 
 
     download.style.display = "inline"; download.href = result.children[0].toDataURL(); 
 
    }); 
 
} 
 

 
function downloadImage() { 
 
\t \t 
 
} 
 

 
document.getElementById("button").onclick = renderContent; 
 
download.onclick = downloadImage
#content { 
 
    position: absolute; 
 
    width: 300px; 
 
    height: 200px; 
 
    border: 5px solid red; 
 
    overflow: hidden; 
 
} 
 

 
#img1 { 
 
    width: 300px; 
 
    height: 200px; 
 
    position: absolute; 
 
    z-index: 5; 
 
} 
 

 
#img2 { 
 
    position: absolute; 
 
    z-index: 6; 
 

 
    width: 150px; 
 
    height: 190px; 
 
} 
 

 
#img3 { 
 
    position: absolute; 
 
    z-index: 7; 
 
    width: 200px; 
 
    height: 100px; 
 
} 
 

 
#download { 
 
    display: none; 
 
}
<script src="https://rawgit.com/niklasvh/html2canvas/master/dist/html2canvas.min.js"></script> 
 

 
<div id="content"> 
 
    <img id="img1" src="https://torcdesign.com/shirts/brown.jpg"> 
 
    <img id="img2" src="https://torcdesign.com/shirts/kiwi.jpg"> 
 
    <img id="img3" src="https://torcdesign.com/shirts/lswhite.jpg"> 
 
</div> 
 
<br><br><br><br><br><br><br><br><br><br><br><br> 
 
<input id="button" type="button" value="convert div to image"><br> 
 
<h3>result:</h3> 
 
<div id="result"></div> 
 
<a id="download" download="my_image.png" href="#">Download image</a>

+0

'downloadImage'没有函数体? – guest271314

+0

没必要。检查行'Download image' –

+0

您的网站似乎适用于Chrome和Firefox。你确定它不适合你吗?我可以从你的div下载'my_image.png'。 –

回答

3

我想你可能必须更新大部分的浏览器。根据this referencea标记的download属性受不同版本的不同浏览器支持。

相关问题