HighDots Forums  

VML and IE 8

Javascript JavaScript language (comp.lang.javascript)


Discuss VML and IE 8 in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andrew Poulos
 
Posts: n/a

Default VML and IE 8 - 04-05-2009 , 01:13 AM






Is dynamically generated VML in IE 8 broken?

If I add one simple shape to page all is well. If I try adding multiple
shapes of shapes with shadows or fills then either only the first item
appears or no item appears.

Of course the code works fine in IE 6 and 7.

All I could get from th eMS web sites is to change this:

document.namespaces.add("v", "urn:schemas-microsoft-com:vml");

to this

document.namespaces.add("v", "urn:schemas-microsoft-com:vml",
"#default#VML");

Andrew Poulos

Reply With Quote
  #2  
Old   
Andrew Poulos
 
Posts: n/a

Default Re: VML and IE 8 - 04-05-2009 , 03:58 AM






Andrew Poulos wrote:
Quote:
Is dynamically generated VML in IE 8 broken?

If I add one simple shape to page all is well. If I try adding multiple
shapes of shapes with shadows or fills then either only the first item
appears or no item appears.

Of course the code works fine in IE 6 and 7.
Since I've been editing the code to try to get it to work in IE 8 it now
doesn't work correctly in IE 6, 7 or 8.

Here's the relevant part of the latest code. Only the first shape ever
gets drawn. All calls to drawVMLShape after the first call never seem to
produce any VML.

var m, shapes = [], ss, doc = document;

shapes[0] = ["filled ellipse", "#7FFFD4", 10, 96, 308, 339, 183];
shapes[1] = ["ellipse", "#00FF00", 3, 16, 124, 234, 201];

// create xmlns
doc.namespaces.add("v", "urn:schemas-microsoft-com:vml", "#default#VML");
// setup css
ss = doc.createStyleSheet();
ss.cssText = "v\\:*{behavior:url(#default#VML)}";

function drawVMLShape(shapeType,filled) {
var filled = filled || false;

var e = doc.createElement("v:" + shapeType);
e.style.position = "absolute";
e.style.left = shapes[i][3] + "px";
e.style.top = shapes[i][4] + "px";
e.style.width = shapes[i][5] + "px";
e.style.height = shapes[i][6] + "px";

e.strokeweight = shapes[i][2] + "px";
e.strokecolor = shapes[i][1];

if (filled) {
e.fillcolor = shapes[i][1];
} else {
e.filled = "false";
}

return e;
}

function drawVMLLine() {
// TODO
}

for (i = 0; i < shapes.length; i++) {
switch (shapes[i][0]) {
case "filled rect":
m = drawVMLShape("rect", "rect", true);
case "rect":
m = drawVMLShape("rect");
break;
case "filled ellipse":
m = drawVMLShape("oval", "ellipse", true);
break;
case "ellipse":
m = drawVMLShape("oval");
break;
// more cases to add...
}

doc.body.appendChild(m);
}

There are other bugs(?) as well:
- Lines in IE 7 always get drawn at 0, 0 irrespective of the CSS applied
to it
- setting end caps to lines get ignored
- one of the pages on MSDN is believed by AVG to contain a virus trying
to do a VML overflow.

Andrew Poulos


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.