Under normal circumstances, the browser load CSS file generally has 3 sources
(1) The browser default comes with
(2) Loading in the head file of the Web page
(3) Insert in page code
Today, we're going to be able to load CSS files with JavaScript.
Add code below
var fileref = document.createelement (' link '); Fileref.setattribute (' rel ', ' stylesheet '); Fileref.setattribute (' type ') , ' text/css '); Fileref.setattribute (' href ', ' css file path ');d ocument.getelementsbytagname (' head ') [0].appendchild ( FILEREF);
Actual in the browser kernel code in the JavaScript and CSS inside the implementation is originally belong to the C + + level, at the bottom of the call can be made to each other, so from the theoretical level calls the problem is not big.
Contact information
qq:390012381
:d Onghuitalk
Reprint Please specify source: http://blog.csdn.net/lihui130135
Web development javascript Loading CSS File