我在下面的代码转换为查询和工作时遇到问题:
原始javascript:
<script type="text/javascript">
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function stream() {
var active = document.getElementById("start").value == "stop";
getFlashMovie("v1stream").setProperty("src", !active ? document.getElementById('url2').value : null);
</script>
转换和修改的jquery版本:
$(document).ready(function() {
alert ('before');
swfobject.getObjectById("v1stream").setProperty("src", "rtmp://localhost/mystream");
alert ('after');
});
更新
这是使用的HTML
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553534700"
id="v1stream" width="562" height="547"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="/assets/im.swf"/>
<param name="quality" value="high"/>
<param name="bgcolor" value="#000000"/>
<param name="allowFullScreen" value="true"/>
<param name="allowScriptAccess" value="always"/>
<embed src="/assets/v1stream.swf" quality="high" bgcolor="#000000"
play="true" loop="false" quality="high"
allowFullScreen="true"
allowScriptAccess="always"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
答案 0 :(得分:1)
jQuery版本应为:
//wait for document.ready to fire
$(document).ready(function() {
//select an element by ID and then change it's `src` attribute
$('#v1stream').attr('src', "rtmp://localhost/mystream");
});
我不是100%确定这会对您有用,因为我不确定swfobject
脚本在您拨打.setProperty()
时的作用,但是如果您只想更改某个属性你可以用上面的代码完成这个元素。
文档:
document.ready
:http://api.jquery.com/ready/ .attr()
:http://api.jquery.com/attr