IFRAME SRC改变我目前有一些JavaScript,看起来有点像这样:与JavaScript不工作
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
function changeSource(newSource) {
document.getElementById('preview').src = newSource;
}
});
</script>
然后,我有一些HTML,看起来像这样:
<table border=0 class="colors">
<tbody>
<tr>
<td><a onclick="changeSource('http://www.test.com')"><img width="40" src="test.png"/></a></td>
</tr>
</tbody>
</table>
随后的iFrame部分:
<table border=0>
<tbody>
<tr>
<td><iframe id="preview" width="125" height="303" src="test.php" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" hspace="0" vspace="0"></iframe></td>
</tr>
</tbody>
</table>
但是点击标签中的图片iframe的来源不会改变。这是为什么?
工作完美,非常感谢。一旦时间用完,我会接受你的答案。 – user1981730