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?

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #180962
    codeaholic
    Participant

    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?

    #180963
    Paulie_D
    Member

    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?

    #180999
    Paulie_D
    Member

    Frankly, that pretty much went over my head.

    #181000
    nixnerd
    Participant

    Are you wanting to build something like Codecademy?

    #181041
    Paulie_D
    Member
    #181056
    Paulie_D
    Member

    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.

    #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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.