我想通過點擊錨標簽打開影像。我正在使用下面的代碼,它在 Firefox 中運行良好,但不能在控制臺中處理 Chrome 和 Edge 錯誤“”不允許將頂部框架導航到資料 URL:“。我嘗試在 base64 字串的末尾添加 ==,= 但它沒有用。提前致謝。
<a href="data:image/png;base64, '.$b64image.'" target="_blank">View</a>
我試過了
<a href="data:image/png;base64, '.$b64image.'==" target="_blank">View</a>
<a href="data:image/png;base64, '.$b64image.'=" target="_blank">View</a>
uj5u.com熱心網友回復:
這是 chrome 安全限制。您可以通過以下方式繞過它。
function debugBase64(base64URL){
var win = window.open();
win.document.write('<iframe src="' base64URL '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');
}
使用事件偵聽器單擊鏈接時呼叫此函式。
來源
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/363300.html
上一篇:CSS在Safari上變得凌亂
