2017-01-01 13 views
0

なぜ私のウェブサイトは私の電話機で動作しますが、私のコンピュータでは動作しませんでした。IE Chrome chrome fire foxを試してみました。 (丁目のみ)。何が起こっている?ここに私のウェブサイト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 referenceによれば、aタグのdownload属性は、さまざまなバージョンの異なるブラウザでサポートされています。

関連する問題