<head>
<linktype="text/css"rel="stylesheet"href="style/style.css"/>
<scripttype="text/javascript"src="js/jsFile.js"></script>
</head>
We commonly load external javascript (*.js) or css (*.css) file on the page with the aboveway,doesn't we? Actually, we can make use of javascript and DOM implementing dynamically loading those files.We can use operating DOM method to achieve it.For example, load an external javascript file and an external css file with the following function.
functionrequireFile(fileName,fileType)...{
varref;
if(fileType=="js")...{
ref=document.createElement("script");
ref.setAttribute("type","text/javascript");
ref.setAttribute("src",fileName);
}
if(fileType=="css")...{
ref=document.createElement("link");
ref.setAttribute("type","text/css");
ref.setAttribute("rel","stylesheet");
ref.setAttribute("href",fileName);
}
document.getElementsByTagName("head")[0].appendChild(ref);
}
Then. we can use requireFile("js/js.js", "js") to dynamically load js/js.js file or requireFile("style/style.css", "css") to dynamically load style.css file.
That's OK!
分享到:
相关推荐
Dynamically loading classes from DLLs(7KB)
adaptive mesh refinement fortran\An Efficient Dynamically Adaptive Mesh for potentially singular solutions
Beginning JavaScript with DOM Scripting and Ajax is an essential resource for modern JavaScript programming. This completely updated second edition covers everything you need to know to get up-to-...
Beginning JavaScript with DOM Scripting and Ajax is an essential resource for modern JavaScript programming. This completely updated second edition covers everything you need to know to get up-to-...
Class loaders are a powerful mechanism for dynamically loading software components on the Java platform. They are unusual in supporting all of the following features: laziness, type-safe linkage, user...
Loading an external CSS file..523 Formatting ranges of text within a text field... 524 Advanced text rendering525 Working with static text528 Example: Newspaper-style text formatting... 529 Reading ...
A reconfigurable antenna is an antenna capable of modifying dynamically its frequency and radiation properties in a controlled and reversible manner.[2] In order to provide a dynamical response, ...
JavaScript权威指南 犀牛书 Chapter 1. Introduction to JavaScript Section 1.1. JavaScript Myths Section 1.2. Versions of JavaScript Section 1.3. Client-Side JavaScript Section 1.4. JavaScript ...
Pecht, “Deep Residual Networks with Dynamically Weighted Wavelet Coefficients for Fault Diagnosis of Planetary Gearboxes,” IEEE Transactions on Industrial Electronics, vol. 65, no. 5, pp. 4290-4300...
Server-side validation and/or client-side JavaScript validation Optional search features (Quick, Extended Quick and Advanced) with search result highlight Optional User ID and User Level Advanced ...
JavaScript
JavaScript
In particular, it examines the paradigms for dynamically loading new classes at runtime, and forwarding messages to other objects. It also provides information about how you can find information about...
Learn CSS, JavaScript, PHP, and more with this vital guide to ...Chapter 13: Foundation – a Responsive CSS/JavaScript Framework Chapter 14: Node.js Appendix: Bootstrap – an Alternative to Foundation
Morris W. Hirsch Stephen Smale Robert L. Devaney
Create and publish your own interactive data visualization projects on the Web—even if you have little or no experience with data visualization or web development. It’s easy and fun with this ...
Dynamically Programmable DRU for High-Speed Serial I/O
4.20 Finding a File Given an Arbitrary Search Path 4.21 Finding a File on the Python Search Path 4.22 Dynamically Changing the Python Search Path 4.23 Computing Directory Sizes in a Cross-...
<br/>The details of permissions are specified by an XML security policy file. Each level maps to a specific file. The default mappings: <br/>admin设置 admin.config default设置 default....