将对象的部分参数值替换为定位点中的值

Replacing part of an object's param value with value from an anchor?

本文关键字:定位 替换 参数 对象      更新时间:2023-09-26

如果你有以下条件:

<object type="application/x-shockwave-flash" height="609" width="1000" id="live_embed_player_flash" data="http://www.twitch.tv/widgets/live_embed_player.swf?channel=jonnyflyspeed" bgcolor="#000000">
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="always" />
<param name="allowNetworking" value="all" />
<param name="movie" value="http://www.twitch.tv/widgets/live_embed_player.swf" />
<param name="flashvars" value="hostname=www.twitch.tv&channel=CHANNELNAMEHERE&auto_play=true&start_volume=75" />
</object>

有没有办法更改value="hostname=www.twitch.tv&channel=CHANNELNAMEHERE&auto_play=true&start_volume=75",特别是使用普通文本链接的 CHANNELNAMEHERE 部分的值?例如:

<a href="#" value="NEWCHANNELNAME">

通过重新加载具有新细节的整个对象对其进行排序:

链接是:

<a onclick="changeChannel('CHANNELNAME')">
<script>
function changeChannel(intValue){
    document.getElementById("test").innerHTML = '<object type="application/x-shockwave-flash" height="609" width="1000" id="live_embed_player_flash" data="http://www.twitch.tv/widgets/live_embed_player.swf?channel='+intValue+'" bgcolor="#000000"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="movie" value="http://www.twitch.tv/widgets/live_embed_player.swf" /><param name="flashvars" value="hostname=www.twitch.tv&channel='+intValue+'&auto_play=true&start_volume=75" /></object>'
}
</script>