Javascript在IE8中不起作用 [英] Javascript doesn't work in IE8

查看:102
本文介绍了Javascript在IE8中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的页面的onload上动态创建这个html元素,当我运行它时,代码不会在IE8上工作,但在Firefox,Safari和其他文件中也可以。

I am trying to create this html elements dynamically on the onload of my page,however;when I run it the code wont work on IE8 but okay in firefox,safari,and others.


 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);
           }


任何人都可以更正我的代码?

Can anyone correct my code?

推荐答案

除非您有非常好的理由手动构建您的Flash,包括DOM元素,请考虑将代码替换为一个框架,如 SWFObject ,为您做所有的脏工作。

Unless you have a really good reason to build your Flash including DOM elements manually, consider replacing the code with a single call to a framework like SWFObject that does all the "dirty work" for you.

swfobject.embedSWF("flashmovie.swf", "container", "512", "296", "9.0.0",
    "expressInstall.swf", { allowFullScreen : true });

这篇关于Javascript在IE8中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆