0

我在 html 文档中有此文本

<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&amp;clid=22753&amp;autoplay=true&amp;noad=&amp;
    did=1000806817&amp;&amp;cache_buster=634916059503671812&amp;session_id=806817&amp;
    break_number=0&amp;user_id=-1&amp;VAST=2&amp;is_hiro=true">
    <param name=...

我想将最后一个 true 更改为 false is_hiro=true->is_hiro=false 我该怎么做?

4

1 回答 1

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');

请注意,这假设您的参数是对象的第一个孩子。
如果情况并非总是如此,最好给参数 a id

<param name="movie"
    id="myParameter"
    value="/play/skins/flash/22753/a.swf?
        movid=blfgbd&amp;clid=22753&amp;autoplay=true&amp;noad=&amp;
        did=1000806817&amp;&amp;cache_buster=634916059503671812&amp;
        session_id=806817&amp; break_number=0&amp;user_id=-1&amp;
        VAST=2&amp;is_hiro=true">
var param = document.getElementById('myParameter'); // Get the <param> tag.
param.value = param.value.replace('is_hiro=true', 'is_hiro=false');
于 2012-12-20T11:35:38.670 回答