Is it possible to add code in an iframe?
I need to add external CSS to <head></head> . Is it possible to implement this with JS?
Is it possible to add code in an iframe?
I need to add external CSS to <head></head> . Is it possible to implement this with JS?
If on different domains, then only using JS is not . (Same-origin policy or Domain Restriction Rule)
The restriction of “ one source ” prohibits windows and frames from different sources from calling each other’s methods and reading data from each other.
At the same time "from one source" means "the protocol, domain and port match ".
If on the same domain, then the usual JS like this:
var cssLink = document.createElement("link") cssLink.href = "style.css"; cssLink.rel = "stylesheet"; cssLink.type = "text/css"; frames['nameOfElementIframe'].document.body.appendChild(cssLink); Source: https://ru.stackoverflow.com/questions/571551/
All Articles