Reputation: 25287
document.getElementById("myFrame").setAttribute("src") = "http://www.yahoo.com/";
myFrame is an iframe element... when entering this into the chrome developer console, it gives me the error "Invalid left-hand side in assignment" I am trying to update the iframe. Is there a method I am forgetting?
Upvotes: 0
Views: 176
Reputation: 15143
Try this...
document.getElementById("myFrame").setAttribute("src","http://www.yahoo.com/");
Upvotes: 0
Reputation: 17734
You can't assign an function call to something, try this instead:
document.getElementById("myFrame").setAttribute("src", http://www.yahoo.com/");
Upvotes: 1
Reputation: 237865
You don't really need setAttribute
when setting the src
property:
document.getElementById('myFrame').src = 'http://www.yahoo.com/';
Upvotes: 3
Reputation: 21090
Here, I fixed it
document.getElementById("myFrame").setAttribute("src", "http://www.yahoo.com/");
Upvotes: 0
Reputation: 159905
setAttribute
takes two arguments:
document.getElementById("myFrame").setAttribute("src", "http://www.yahoo.com/");
You are trying to set the DOM object to the string "http://www.yahoo.com/"
... which is invalid.
Upvotes: 3