Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript getElementByID可以在firefox中使用,但不能在IE&;铬 函数change1(){ document.getElementById(“video”).src=document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value } 测试1 测试2_Javascript_Html - Fatal编程技术网

Javascript getElementByID可以在firefox中使用,但不能在IE&;铬 函数change1(){ document.getElementById(“video”).src=document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value } 测试1 测试2

Javascript getElementByID可以在firefox中使用,但不能在IE&;铬 函数change1(){ document.getElementById(“video”).src=document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value } 测试1 测试2,javascript,html,Javascript,Html,上述代码可以在Firefox中使用,但不能在IE和Chrome中使用。尝试以下方法: function change1() { document.getElementById("video").src = document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value } <form name="myvid1"> <select id="vid_select" onChan

上述代码可以在Firefox中使用,但不能在IE和Chrome中使用。

尝试以下方法:

function change1() { 
document.getElementById("video").src = document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value
}

<form name="myvid1">
<select id="vid_select" onChange="change();">
<option value="http://www.youtube.com/v/nN8Si5LKyY?autoplay=1">Test1</option>
<option value="http://www.youtube.com/v/CdKUtZIDzEg?autoplay=1">Test2</option>
</select>
</form>

<object width="650" height="450">
<embed id="video" src="http://www.youtube.com/v/IiJx4a1cxRk" type="application/x-shockwave-flash" width="650" height="450" />
</object>

函数更改()
{ 
var html='';
document.getElementById(“div视频”).innerHTML=html;
}
测试1
测试2
试试这个:

function change1() { 
document.getElementById("video").src = document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value
}

<form name="myvid1">
<select id="vid_select" onChange="change();">
<option value="http://www.youtube.com/v/nN8Si5LKyY?autoplay=1">Test1</option>
<option value="http://www.youtube.com/v/CdKUtZIDzEg?autoplay=1">Test2</option>
</select>
</form>

<object width="650" height="450">
<embed id="video" src="http://www.youtube.com/v/IiJx4a1cxRk" type="application/x-shockwave-flash" width="650" height="450" />
</object>

函数更改()
{ 
var html='';
document.getElementById(“div视频”).innerHTML=html;
}
测试1
测试2

尝试此操作,以避免任何潜在的浏览器特定选择器混淆:

<script type="text/javascript">
    function change() 
    { 
        var html = '<object width="650" height="450"> <embed id="video" src="';

        html += document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value;
        html += '" type="application/x-shockwave-flash" width="650" height="450"/>';

        document.getElementById("div-video").innerHTML = html;
    }
</script>

<form name="myvid1">
    <select id="vid_select" onChange="change();">
        <option value="http://www.youtube.com/v/IiJx4a1cxRk">Test1</option>
        <option value="http://www.youtube.com/v/CdKUtZIDzEg?autoplay=1">Test2</option>
    </select>
</form>

<div id="div-video">
    <object width="650" height="450">
        <embed id="video" src="http://www.youtube.com/v/IiJx4a1cxRk" type="application/x-shockwave-flash" width="650" height="450" />
    </object>
</div>

功能更改(newsrc){
document.getElementById('video').src=newsrc;
}
测试1
测试2

尝试此操作,以避免任何潜在的浏览器特定选择器混淆:

<script type="text/javascript">
    function change() 
    { 
        var html = '<object width="650" height="450"> <embed id="video" src="';

        html += document.myvid1.vid_select.options[document.myvid1.vid_select.selectedIndex].value;
        html += '" type="application/x-shockwave-flash" width="650" height="450"/>';

        document.getElementById("div-video").innerHTML = html;
    }
</script>

<form name="myvid1">
    <select id="vid_select" onChange="change();">
        <option value="http://www.youtube.com/v/IiJx4a1cxRk">Test1</option>
        <option value="http://www.youtube.com/v/CdKUtZIDzEg?autoplay=1">Test2</option>
    </select>
</form>

<div id="div-video">
    <object width="650" height="450">
        <embed id="video" src="http://www.youtube.com/v/IiJx4a1cxRk" type="application/x-shockwave-flash" width="650" height="450" />
    </object>
</div>

功能更改(newsrc){
document.getElementById('video').src=newsrc;
}
测试1
测试2

我想从下拉菜单中选择源,然后播放视频。您是否知道您的选择正在调用change(),但您将函数定义为change1()?我想从下拉菜单中选择源,然后播放视频。您知道您的选择正在调用change()吗但是您将函数定义为change1()?请在回答中解释您更改了什么以及为什么此代码可以工作我在函数周围添加了标记以便它们可以运行。标记不允许设置src属性。我刚刚安装了IE 10和Chrome,但它在那里不起作用,所以我把标签放在了一个盒子里。函数的作用是:重新创建视频中的整个和标记,从而强制加载视频。我刚刚注意到我忘记关闭函数中的标记,但它仍然有效。或者,您也可以只围绕并重新创建,而不是执行and。通过将
select
的值作为变量直接传递给
change()
函数,可以使此解决方案更简洁,正如我在下面的回答中所做的。请在你的回答中解释你更改了什么,以及为什么这段代码有效。我在函数周围添加了标记,以便它们可以运行。标记不允许设置src属性。我刚刚安装了IE 10和Chrome,但它在那里不起作用,所以我把标签放在了一个盒子里。函数的作用是:重新创建视频中的整个和标记,从而强制加载视频。我刚刚注意到我忘记关闭函数中的标记,但它仍然有效。或者,您也可以只围绕并重新创建,而不是执行and。通过将
select
的值作为变量直接传递给
change()
函数,此解决方案将变得更干净,正如我在下面的回答中所做的那样。不确定为什么投票被否决,但这里的解决方案更干净@DiMono,我想再解释一下你的答案。我所做的只是将
select
的值作为变量传递,而不是从函数中获取它。这更多的是作为一个临时步骤来删除一些移动部件,但我肯定认为这是一个更干净的方法来处理获取值。不知道为什么这会被否决,但这里的解决方案更干净@DiMono,我想再解释一下你的答案。我所做的只是将
select
的值作为变量传递,而不是从函数中获取它。它更多的是作为一个临时步骤来删除一些移动部件,但我肯定认为它是一种更干净的方法来处理获取值。