How do you change source location of iframes in JavaScript?
For example, but the click of a button or a link, change this:
<iframe src=""></iframe>
...into this:
<iframe src="http://stackoverflow.com/"></iframe>
And, if you want to do one better, how do I change multiple iframes within the same page (using name
or some other identifier)?
First, assign you iframe an id. This would look like
<iframe id="youridname" src=""></iframe>;.
Then your JavaScript command would be
document.getElementById("youridname").src = "http://stackoverflow.com";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With