Home > front end >  Dynamic loading CSS
Dynamic loading CSS

Time:10-13

I according to the need for page dynamic load of different styles, how can I get to judge CSS folder of HTML page size and have the following response of the CSS file, and access to the CSS file, how to write such a code,

CodePudding user response:

If a path is to judge the CSS file exists, (that is, to be able to get a clear file name), can use the following method:
 $. Ajax ({
Type: "GET",
Url: your url,
Success: the function (result) {
//if the file exists, then enter the success callback
console.log(result);
},
Error: function (result) {
//if the file does not exist, then enter the error callback
The console. The log (result. Status);//404
}
});


If it is to get all the file name of a directory path, suggestion and implementation code with the background,
  • Related