由于IE11更加遵循W3C规范,所以IE11与低版本IE在加载activeX时有差别。
1、IE11中动态加载activeX的顺序
var objectTag = document.createElement("object");
objectTag.style.height = XPlayPluginDivHeight + "px";
objectTag.style.width = XPlayPluginDivWidth + "px";
objectTag.classid = "CLSID:E6FFE6D3-D4E6-4FDF-8C8B-958801A76784";
XPlayPluginDiv.appendChild(objectTag);
即:创建好object标签后,先设置object的大小,再动态追加该DOM对象。
2、在IE8/9/10中动态加载activeX的顺序
var objectTag = document.createElement("object");
XPlayPluginDiv.appendChild(objectTag);
objectTag.style.height = XPlayPluginDivHeight + "px";
objectTag.style.width = XPlayPluginDivWidth + "px";
objectTag.classid = "CLSID:E6FFE6D3-D4E6-4FDF-8C8B-958801A76784";
即:创建好object标签后,先动态追加DOM对象,再设置该object的大小。
加载activeX顺序不对,会导致IE崩溃。
对上述更相信的解释,参见
https://msdn.microsoft.com/en-us/library/ms537508(v=vs.85).aspx