您的位置:首页 > 移动开发

ie appendChild 意外地调用了方法或属性访问

2016-08-19 19:05 495 查看
ie8
var $ = document.createElement("v:group");
$.style.left = this.x;
$.style.top = this.y;
$.style.width = this.w;
$.style.height = this.h;
$.setAttribute("coordsize", this.w + "," + this.h);
this.el = $;
var B = document.createElement("v:roundrect");
B.style.position = "absolute";
B.style.left = "5px";
B.style.top = "5px";
B.style.width = (this.w - 10) + "px";
B.style.height = (this.h - 10) + "px";
B.setAttribute("id", Gef.id());
B.setAttribute("arcsize", 0.2);
B.setAttribute("fillcolor", "#F6F7FF");
B.setAttribute("strokecolor", "#03689A");
B.setAttribute("strokeweight", "2");
B.style.verticalAlign = "middle";
<span style="color:#FF0000;">$.appendChild(B);</span>
一直报错“意外地调用了方法或属性访问”,浪费了好长时间也解决不了。此功能使用vml画图,对此我又知之甚少,问题又亟待解决。后来有一方法 ,HTML头部改为:

<html xmlns:v="urn:schemeas-microsoft-com:vml">
就好了。

xmlns:v="urn:schemas-microsoft-com:vml"  这句在html文档中,可写,可不写!但在xhtml文档中必须写。它的作用是在文档中定义一个或多个可供选择的命名空间。
[code]xmlns:v是html的属性,它定义了一个命名空间,浏览器会将此命名空间用于该属性所在元素内的所有内容。

[/code]
先记录一下,后续再补充。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  兼容性 ie