我在html doc
中有这个文本<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="" id="movie" align="middle" height="371" width="495">
<param name="movie" value="/play/skins/flash/22753/a.swf?
movid=blfgbd&clid=22753&autoplay=true&noad=&
did=1000806817&&cache_buster=634916059503671812&session_id=806817&
break_number=0&user_id=-1&VAST=2&is_hiro=true">
<param name=...
我想将最后一个true更改为false is_hiro = true-&gt; is_hiro = false 我怎么能这样做?
答案 0 :(得分:1)
这应该有效:
// Get the <param> tag.
var param = document.getElementById('movie').children[0];
// Replace the content of the param's value.
param.value = param.value.replace('is_hiro=true', 'is_hiro=false');
请注意,这假设您的参数是该对象的第一个孩子
如果情况并非总是这样,那么最好给这个参数id
:
<param name="movie"
id="myParameter"
value="/play/skins/flash/22753/a.swf?
movid=blfgbd&clid=22753&autoplay=true&noad=&
did=1000806817&&cache_buster=634916059503671812&
session_id=806817& break_number=0&user_id=-1&
VAST=2&is_hiro=true">
var param = document.getElementById('myParameter'); // Get the <param> tag.
param.value = param.value.replace('is_hiro=true', 'is_hiro=false');