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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    appendChild js right after title tag

    PHP Code:
    function ()
    {

        var 
    js document.createElement("script");
        
    js.setAttribute("language""JavaScript");
        
    js.setAttribute("type""text/javascript");
        
    js.setAttribute("src""js/keepieapart.js");
        
    document.getElementsByTagName('head').item(0).appendChild(js);
        

    How to include Js right after title tag, need to check Nodes ?? How to?

  • #2
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PHP Code:
     function ()
    {

        var 
    js document.createElement("script");
        
    js.setAttribute("language""JavaScript");
        
    js.setAttribute("type""text/javascript");
        
    js.setAttribute("src""js/keepieapart.js");

        if (
    document.getElementsByTagName('head').item(0).hasChildNodes()) {
            
    document.getElementsByTagName('head').item(0).firstChild.insertBefore(js);
        } else {
            
    document.getElementsByTagName('head').item(0).appendChild(js);
        }


  • #3
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Code:
    function ()
    {
    
        var js = document.createElement("script");
        js.setAttribute("language", "JavaScript");
        js.setAttribute("type", "text/javascript");
        js.setAttribute("src", "js/keepieapart.js");
    	
    	document.getElementsByTagName('head').item(0).insertBefore(js, document.getElementsByTagName('title').item(0).nextSibling);
    }
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).

  • #4
    Regular Coder
    Join Date
    Mar 2005
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How to make this a trixie userscript

    the external script: <www.quirksmode.org/browsers/multipleie.html >


  •  

    Posting Permissions

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