Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Can you put CSS style inside of a JavaScript src? Reply To: Can you put CSS style inside of a JavaScript src?

#181058
__
Participant

In there a way to “include”/”inject” an additional plain old inline style sheet “cross domain”?

link it. If you really don’t want the user to do it (and I don’t see why not; it’s not that complicated), do it via javascript.

var l = document.createElement('link');
l.setAttribute('href','http://example.com/stylesheet.css');
l.setAttribute('rel', 'stylesheet');
l.setAttribute('type','text/css');
document.head.appendChild(l);

However, Paulie is right: this seems much more “sneaky” and untrustworthy than just instructing the user to add it to their page themselves.