forked from shimondoodkin/style.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
style.js
35 lines (32 loc) · 975 Bytes
/
style.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*! * $style.js - a tiny css loader
* https://github.com/shimondoodkin/style.js
* (c) Shimon doodkin 2012
* License: MIT */
function $style(css){
var style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) { // IE
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
document.getElementsByTagName('head')[0].appendChild(style);
}
$style.url=function(url){
var style = document.createElement('link');
style.rel="stylesheet"
style.type = 'text/css';
style.href= url;
document.getElementsByTagName('head')[0].appendChild(style);
}
//usage:
//
//$style.url('/stylesheets/orders.css');
//$style.url('http://123.123.123.123:5051/stylesheets/orders.css');
//$style('.example {'+
// ' width : 90%;'+
// ' height: 90%;'+
// ' margin: 8px auto;'+
// '} '+
// //+'.item{border:1px solid lightgray;padding:10px;}'+
// '')