0
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?

1

5 Answers 5

3

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.

Sign up to request clarification or add additional context in comments.

Comments

3

You don't really need setAttribute when setting the src property:

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

Comments

1

You can't assign an function call to something, try this instead:

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

Comments

0

Here, I fixed it

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

Comments

0

Try this...

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.