0
我製作了一個簡單的SVG,使用Javascript進行動畫製作。它可以與Chrome,Firefox,Opera等完美兼容。但它不適用於TOR和Internet Explorer。JavaScript + SVG在Tor&IE上不起作用
我檢查過Tor和Internet Explorer是否啓用了JavaScript,答案是肯定的。如何在一個能夠運行JS的瀏覽器上使用JS的簡單動畫無法正確顯示?這是特定於SVG嗎?
這裏是什麼,我想在這些瀏覽器(尤其是Tor的TBH)運行一個簡單的例子:'
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="720" height="720" viewBox="0 0 720 720">
<g transform="translate(360,360)">
<line id="hand" transform="rotate(0)" stroke-width="4" y1="0" y2="0" stroke-linecap="round" stroke="black"/>
</g>
</svg>
<script>
function sleep(ms)
{
return new Promise(resolve => setTimeout(resolve, ms));
}
async function run()
{
var x = 0;
while (x < 360)
{
await sleep(10);
h.setAttribute("y2",x.toString());
h.setAttribute("transform","rotate(" + x.toString() + ")");
x = x + 1;
}
}
var h = document.getElementById("hand");
run();
</script>
檢查[支持異步功能](http://caniuse.com/#feat=async-functions) – James
它不工作,因爲Firefox不支持異步功能,直到版本52.0和當前版本的Tor瀏覽器基於在Firefox 45.9 ESR上。同樣,IE瀏覽器直到Edge 15都沒有。 – drew010
謝謝你們倆。 – Cervidae