如果用JS来选择性加载Flash?
我想完成的效果是:在一个页面中,有多个按钮分别对应多个flash,页面默认无flash加载。
当点击flash的时候,新建新的div层并且在该层中加载flash,这个div可以随时关闭。。
下面是我一个测试,但是无法正常加载flash,哪里出现问题了?
程序代码:
<head> <title>测试你妹</title> <script type="text/javascript" src="swfobject.js"></script> <script type="text/javascript"> swfobject.registerObject("myFlashContent", "9.0.0"); </script> <style> body {background:#ccc;} </style> <script LANGUAGE="JavaScript"> function nimei(){ var txt=document.createElement("div"); txt.innerHTML=flashcode(); document.body.appendChild(txt); } function flashcode(){ var flash_code; flash_code = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"800\" height=\"600\" id=\"myFlashContent\">"; flash_code += "\n<param name=\"movie\" value=\"dingzihu.swf\">"; flash_code += "\n<!--[if !IE]>-->"; flash_code += "\n<object type=\"application/x-shockwave-flash\" data=\"dingzihu.swf\" width=\"800\" height=\"600\">"; flash_code += "\n<!--<![endif]-->"; flash_code += "\n<a href=\"http://www.\">"; flash_code += "\n<img src=\"http://www.\" alt=\"Get Adobe Flash player\" />"; flash_code += "\n</a>" flash_code += "\n<!--[if !IE]>-->"; flash_code += "\n</object>" flash_code += "\n<!--<![endif]-->"; flash_code += "\n</object>"; return flash_code; } </script> </head> <body> <p onclick="javascript:nimei();">点击我测试</p> </body>