这是一个奇怪的现象。我有一个在JavaScript中动态创建的VML对象的集合。我用来测试的系统是Windows XP上的IE6(SP3)VML在鼠标按下时发生错误 - '失败'
当您在集合上按下鼠标时,会引发奇怪的'失败'错误。真奇怪的是,我一直在使用VML一段时间,我发誓这个错误在上周没有发生。
无论如何,这里是显示错误的演示的链接。
http://www.codequark.com/vml-demo
错误是:
行:25 字符:5 错误:无法 代码:0
可爱。我使用的是IE6,但是这将是有益知道,如果它发生在7或8
这里是唯一的其他引用任何接近这个错误我已经能够找到:
如果你想,这里是源代码。您可以加载它并在您选择的野蛮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>
任何帮助表示赞赏。谢谢!