Dynamically changing the src of an iFrame

-3

Can I change the src of an iframe by any value? Is this possible?

document.getElementById('idIframe').src = "www.google.com"
    
asked by anonymous 20.06.2016 / 17:46

1 answer

1

How are you doing is correct. You have to keep in mind two things:

  • Some urls do not open within iframes by CORS protection , which prevents them from manipulating the page within a iframe
  • src must be a valid url. Either you place a relative url (as in the example I gave) or you put a full address with http://

Example: link

    
20.06.2016 / 21:16