Skip to content Skip to sidebar Skip to footer

Adding Css To A Javascript Widget

I am developing a Javascript widget for other websites to consume. I have 2 javascripts and one php file. One Javascript for user to consume and other to make a JSON request and th

Solution 1:

you could append it to the head of the page via javascript

var fileref=document.createElement("link");
  fileref.setAttribute("rel", "stylesheet");
  fileref.setAttribute("type", "text/css");
  fileref.setAttribute("href", "filename.css");
  document.getElementsByTagName("head")[0].appendChild(fileref);

Solution 2:

i don`t get your idea but at all css code have 3 ways

first be inside html page like this

<head><title>hello</title><styletype="text/css">body
{
background-color: #CC0000;
}
</style></head>

second have page and include it with html page like this the page save like name "sheet.css" and include it before close head like this

<link rel="stylesheet" href="css/sheet.css" media="screen"/>

the last way from js page like this

$("body").css("background-color","#CC0000");

Post a Comment for "Adding Css To A Javascript Widget"