Javascript循环隐藏所有闪存

ica*_*ant 3 javascript flash

如何让JavaScript循环离开所有<object>元素并隐藏它们?

mpl*_*jan 9

var objects = document.getElementsByTagName('object');
for (var i=0, n=objects.length;i<n;i++) objects[i].style.display='none';
Run Code Online (Sandbox Code Playgroud)

更新.玩弄我以前想过的东西.它在Fx中与对象一起工作,但是虽然我可以在IE中使用div工作,但我无法在IE中工作 - 甚至在对象上都没有类名.

<html>
<head>
<title></title>
<style type="text/css">
object {
  display:block;
}
</style>
<script type="text/javascript">
// got some of this from http://www.javascriptkit.com/dhtmltutors/externalcss3.shtml
function toggle() {
  var mysheet=document.styleSheets[0]
  var firstrule=mysheet.cssRules? mysheet.cssRules[0]: mysheet.rules[0]
  firstrule.style.display=(firstrule.style.display=="block")?"none":"block"
  return false
}

</script>
</head>
<body>
<a href="#" onClick="return toggle()">toggle the objects</a><br />
<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/tgbNymZ7vqY?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/tgbNymZ7vqY?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/VnT7pT6zCcA?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/VnT7pT6zCcA?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/PhMCa1_9FYg?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/PhMCa1_9FYg?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)