- This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
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?
I’m trying to do it and its not working.
This is my html code where I’m trying to do it.
<script src="http://www.salescart.net/checkout20/src/SCIframeSize.js"></script>
<script <iframe id="testframe" src="http://www.salescart.net/checkout20/default.aspx" width="100%" class="SCIFrame01" allowtransparency="true" scrolling="no"></iframe>
<p id="callback"></p>
The file SCIframeSize.js has the CSS class code definition for for SCIFrame01 but its giving me an error on line 11 which is the first line of the style tag….so maybe you can’t do this?
Unfortunately you code did not come through.
It’s not clear to me what you are trying to do.
Are you trying to inject CSS into an iframe?
Frankly, that pretty much went over my head.
Are you wanting to build something like Codecademy?
This
http://stackoverflow.com/questions/217776/how-to-apply-css-to-iframe/217833#217833
or this
http://stackoverflow.com/questions/6960406/add-css-to-iframe
Not cross domain though AFAIK.
Yes, I have to be able to do this “cross domain”.
I’m not sure this is even possible…I certainly wouldn’t want some random person injecting their code into my website.
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.