我想在Internet Explorer 9上使用jQuery與內聯SVG。這是非常基本的東西,但我似乎無法得到它的工作。我想要做的就是使用jQuery在單擊矩形時「提醒」。下面是我試過的代碼:SVG,jQuery和Internet Explorer
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<script type="text/ecmascript" xlink:href="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" />
<script type="text/ecmascript"><![CDATA[
$(document).ready(function(){
$("#bot").click(function(){
alert("clicked");
});
});
]]></script>
<rect x="10" y="10" height="300" width="300" style="fill: #000000" id="bot" />
</svg>
<!--
<script type="text/javascript" href="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" />
<script type="text/javascript"><![CDATA[
$(document).ready(function(){
$("#bot").click(function(){
alert("clicked");
});
});
]]></script>
-->
我可以在矩形上點擊儘可能多,但沒有任何反應。有誰知道爲什麼以及如何在Internet Explorer 9中修復它(在Firefox中工作正常),只使用普通的jQuery而沒有其他庫?
正如你所看到的,我已經嘗試將JS部件放在SVG標籤的內部和外部,看看是否有任何影響。它沒!
要注意的是,上面的示例在Chrome 23中也不起作用。 –