这是一个奇怪的问题。我有一组用 javascript 动态创建的 VML 对象。我用来测试的系统是 Windows XP (SP3) 上的 IE6
当您在集合上按下鼠标时,它会抛出一个奇怪的“失败”错误。真正奇怪的是,我使用 VML 已经有一段时间了,我发誓截至上周没有发生此错误。
无论如何,这里有一个演示链接,它显示了错误。
http://www.codequark.com/vml-demo
错误是:
行:25 字符:5 错误:失败代码:0
迷人的。我正在使用 IE6,但知道它是在 7 还是 8 中发生会很有帮助。
以下是我能够找到的与此错误接近的唯一其他参考:
http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/dfacff65-cd23-480f-a2e9-c928e63cb50f/
我的网站不断崩溃 IE,无法调试
如果你愿意,这里是源代码。您可以加载它并在您选择的野蛮 IE 浏览器中查看它。
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript" charset="utf-8">
//the stage element.
var stage;
//create a group with a single square shape.
function makeAScaledRotatedGroup(sclX, sclY, rot, clr) {
var xCoord = 200;
var yCoord = 200;
var regX = 100;
var regY = 100;
var origX = -10/sclX + regX;
var origY = -10/sclY + regY;
var _x = xCoord - 10;
var _y = yCoord - 10;
var grp = document.createElement('<v:group style="position:absolute; left:'+_x+'px; top:'+_y+'px; width:20px; height:20px; rotation:'+rot+';" coordsize="'+20/sclX+' '+20/sclY+'" coordorigin="'+origX+' '+origY+'" class="rvml">');
var shp1 = document.createElement('<v:shape fillcolor="'+clr+'" strokecolor="red" strokeweight="2px" coordorigin="0 0" coordsize="20 20" style="position:absolute; top:0px;left:0px;width:20px;height:20px;" class="rvml">');
var pth1 = document.createElement('<v:path v="M 0 0 L 200 0 200 200 0 200 X E" class="rvml">');
shp1.appendChild(pth1);
grp.appendChild(shp1);
stage.appendChild(grp);
return grp;
}
//array to store references to all the dom nodes.
var allRects = [];
//kick it off. mon calamari cruisers beware.
function operationalBattleStation() {
document.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");
document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
stage = document.createElement('div');
stage.style.position = 'absolute';
stage.style.top = '0px';
stage.style.left = '0px';
stage.style.width = '500px';
stage.style.height = '500px';
stage.style.clip = "rect(0px,500px,500px,0px)";
document.body.appendChild(stage);
var clrs = ['#0066CC', '#990000','#FF0033','#0699CC','#00FF00','#0000FF','#FF0000','#33FF00','#333300', '#990000','#FF0033','#0699CC','#00FF00','#0000FF','#FF0000','#33FF00','#333300'];
var rot =0;
var scl = 1;
for(var h=0; h<clrs.length; h++) {
allRects.push(makeAScaledRotatedGroup(scl, scl, rot, clrs[h]));
rot+=10;
scl = scl*0.7;
}
};
</script></head><body onload="operationalBattleStation();"></body></html>
任何帮助表示赞赏。谢谢!