簡體   English   中英

網站可以在某些瀏覽器中運行,但不是全部

[英]website works in some browsers but not all

為什么我的網站可以在手機上正常運行,但不能在計算機上正常運行,所以我嘗試了所有IE chrome Firefox瀏覽器,但似乎無法從div下載圖像,但是當我使用手機時,它可以正常工作(僅在家)。 怎么了? 這是我的網站https://torcdesign.com/mom有人可以幫助我找到一種適用於所有瀏覽器的解決方案

 var download = document.getElementById("download"), result = document.getElementById("result"); function renderContent() { html2canvas(document.getElementById("content"), { allowTaint: true }).then(function(canvas) { result.appendChild(canvas); download.style.display = "inline"; download.href = result.children[0].toDataURL(); }); } function downloadImage() { } 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> 

我認為您可能必須更新大多數瀏覽器。 根據此參考 ,不同瀏覽器的不同版本支持a標簽的download屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM