Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamically Add Javascript Code Problem

    I am making an ajax website that dynamically adds javascript and css code to pages.

    My code is as follows:
    Code:
    var head = document.getElementsByTagName("head")[0];
    var script = document.createElement('script');
    script.id = 'content_script';
    script.type = 'text/javascript';
    script.innerHTML=js_string;
    head.appendChild(script);
    This works fine and does as expected in Firefox. However in Internet Explorer (IE 6) it does not like it and gives me the ever helpful error msg "unknown runtime error"


    I have tried script.appendChild(js_string) but that gives me errors in both browsers.

    Does anyone know what the way to do it in IE is?
    Last edited by Petty_Crim; 05-18-2009 at 01:36 PM.

  • #2
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok updated. I have worked out how to do add the javascript code you use script.text=js_string;


    However css_tag.text="css code" is not working.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •