2017-01-01 41 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屬性受不同版本的不同瀏覽器支持。

相關問題