简单的javascript问题

简单的javascript问题,javascript,iframe,Javascript,Iframe,myFrame是一个iframe元素。。。当在chrome开发者控制台中输入这个时,它会给我一个错误“分配中的左侧无效”,我正在尝试更新iframe。有一种方法我忘记了吗?有两个参数: document.getElementById("myFrame").setAttribute("src") = "http://www.yahoo.com/"; 您正在尝试将DOM对象设置为字符串“http://www.yahoo.com/“。。。无效。无法将函数调用分配给某个对象,请尝试以下操作: docu

myFrame是一个iframe元素。。。当在chrome开发者控制台中输入这个时,它会给我一个错误“分配中的左侧无效”,我正在尝试更新iframe。有一种方法我忘记了吗?

有两个参数:

document.getElementById("myFrame").setAttribute("src") = "http://www.yahoo.com/";

您正在尝试将DOM对象设置为字符串
“http://www.yahoo.com/“
。。。无效。

无法将函数调用分配给某个对象,请尝试以下操作:

document.getElementById("myFrame").setAttribute("src", "http://www.yahoo.com/");
我把它修好了

document.getElementById("myFrame").setAttribute("src", http://www.yahoo.com/");
试试这个

document.getElementById("myFrame").setAttribute("src", "http://www.yahoo.com/");

设置
src
属性时,实际上不需要
setAttribute

document.getElementById("myFrame").setAttribute("src","http://www.yahoo.com/");
看见
document.getElementById('myFrame').src = 'http://www.yahoo.com/';