JavaScript 在 IE8 中不起作用

2023-12-20

我试图在页面加载时动态创建这个 html 元素,但是,当我运行它时,代码在 IE8 上不起作用,但在 Firefox、safari 和其他浏览器中可以。


 function getmovie() {
           var container = document.getElementById("container");
           if (!container)
               return;
           var object = document.createElement("object");
           object.setAttribute("width", "512");
           object.setAttribute("height", "296");
           var param1 = document.createElement("param");
           param1.setAttribute("name", "movie");
           param1.setAttribute("value", "url");
           var param2 = document.createElement("param");
           param2.setAttribute("name", "allowFullScreen");
           param2.setAttribute("value", "true");
           var embed = document.createElement("embed");
           embed.setAttribute("src", "my url");
           embed.setAttribute("type", "application/x-shockwave-flash");
           embed.setAttribute("allowFullScreen", "true");
           embed.setAttribute("width", "512");
           embed.setAttribute("height", "296");
           object.appendChild(param1);
           object.appendChild(param2);
           object.appendChild(embed);
           container.appendChild(object);
           }

除非您有充分的理由手动构建包含 DOM 元素的 Flash,否则请考虑通过对框架的一次调用来替换代码,例如SWF对象 http://code.google.com/p/swfobject/它为你做了所有的“脏活”。

swfobject.embedSWF("flashmovie.swf", "container", "512", "296", "9.0.0",
    "expressInstall.swf", { allowFullScreen : true });
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

JavaScript 在 IE8 中不起作用 的相关文章