Search code examples
javascriptcssdojostylesheetexternal

Dojo - Add an External stylesheet outside of the header


I would like to add an external style sheet specified inside of an Ajax call.

I have found a way to do this with jQuery (see the example below), however i need to adapt the method to the dojo JavaScript framework.

JQuery Example

$('head').append('<link rel="stylesheet" type="text/css" href="lightbox_stylesheet.css">');

Thanks.


Solution

  • Once you've included dojo.NodeList-manipulate, it's virtually identical to jQuery:

    dojo.require("dojo.NodeList-manipulate");
    
    dojo.ready(function(){
        dojo.query("head").append('<link rel="stylesheet" type="text/css" href="lightbox_stylesheet.css">');
    });