1

this is a strange one. I have a collection of VML objects created dynamically in javascript. The system I'm using to test is IE6 on Windows XP (SP3)

When you press the mouse down on the collection, it throws a weird 'Failed' error. The really strange thing is that I've been working with VML for a while and I swear this error wasn't happening as of last week.

At any rate, here is a link to a demo which shows the error.

http://www.codequark.com/vml-demo

The error is:

Line:25 Char:5 Error:Failed Code:0

Lovely. I'm using IE6, but it would be helpful to know if it's happening in 7 or 8.

Here are the only other references to anything close to this error I've been able to find:

http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/dfacff65-cd23-480f-a2e9-c928e63cb50f/

My website keeps crashing IE, can't debug

If you want, here is the source code. You can load it up and view it in the barbaric IE browser of your choice.

    <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>

Any help is appreciated. Thanks!

Community
  • 1
  • 1
CodeOwl
  • 662
  • 2
  • 9
  • 23

1 Answers1

1

Oh lord this is one for the books.

Come to find out, this bug and several like it were caused by... wait for it... some kind of tool-bar add-on called "Reganam" which was installed on my version of IE6. Hiding it solved the problem, and now my code is behaving just as it should.

My theory is that this add-on was somehow impacting on IE6's garbage collection system. It's like the VML nodes were deleted even though they still appeared on the screen. In other instances the window.event.srcElement from a VML element would throw the 'Failed' error if you attempted to access any of its properties. But the srcElement was not null. (It behaved just how objective-c behaves when you try to access a property of a freed object) Hiding the add-on solved this problem as well.

Why an add-on would interfere with VML, (and why the browser would be designed so that such interference is even possible) is unfathomable.

The Reganam add-on is bad news for people who have to do cross-browser vector graphics. I'd love to write more, but I have some voodoo dolls to make.

CodeOwl
  • 662
  • 2
  • 9
  • 23