开发者

JS: Why I can not send a value from onclick?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
</head>
<body>
  <li><a href="#" onclick="alink('http://www.youtube.com/v/1a0E5BuvZ28&feature=youtube_gdata?fs=1&hl=en')">vedio1</a></li>
  <li><a href="#" onclick="alink('http://www.youtube.com/v/A6X01URCHZY&feature=youtube_gdata?fs=1&hl=en')">vedio2</a></li>
  <li><a href="#" onclick="alink('http://www.youtube.com/v/SNaJ0SYvcYA&feature=youtube_gdata?fs=1&hl=en')">vedio3</a></li>
  <object width="600" height="320"><param name="movie" id="id" value="http://www.y开发者_JAVA百科outube.com/v/oyzmXMfHIeI&feature=youtube_gdata?fs=1&hl=it"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed id="src" src="http://www.youtube.com/v/oyzmXMfHIeI&feature=youtube_gdata?fs=1&hl=en" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="320"></embed></object>
  <script type="text/javascript" defer="defer">
    function alink($value)
    {
      document.getElementById('id').value = $value;
      document.getElementById('src').src = $value;
    }
  </script>
</body>
</html>

I want make a custom list of youtube vedio. I use javascript code. Why I can not send a value from onclick? It show fault: document.getElementById(...)' null...Thanks.


Of the major browsers, only Firefox lets you dynamically change the source of an embedded flash movie. For this reason, your code will not work in Internet Explorer, Chrome, or Safari (or rather, it will change the source, but to no effect). To get it to work in all browsers, you have to completely rewrite the embedded object to the DOM, in its entirety.

The easiest way to do this is to use the swfobject javascript library. This library not only encapsulates all the functionality to make it very easy to use, but also ensures cross-browser compatibility and deals with edge cases (like if the browser does not have flash installed).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜