您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function DynLoadFile(filename)
  2. {
  3. var filetype = filename.match(/\.[a-zA-Z]+$/);
  4. //if filename is a external JavaScript file
  5. if (filetype == ".js")
  6. {
  7. var fileref = document.createElement('script');
  8. fileref.setAttribute("type","text/javascript");
  9. fileref.setAttribute("src", filename);
  10. }
  11. //if filename is an external CSS file
  12. else if (filetype == ".css")
  13. {
  14. var fileref = document.createElement("link");
  15. fileref.setAttribute("rel", "stylesheet");
  16. fileref.setAttribute("type", "text/css");
  17. fileref.setAttribute("href", filename);
  18. }
  19. if (fileref)
  20. document.getElementsByTagName("head")[0].appendChild(fileref);
  21. }
  22. function DynRemoveFile(filename)
  23. {
  24. var filetype = filename.match(/\.[a-zA-Z]+$/);
  25. var targetelement = "none";
  26. var targetattr = "none";
  27. //Determine element type to create nodelist from and corresponding attribute to test for
  28. if (filetype==".js")
  29. {
  30. targetelement = "script";
  31. targetattr = "src";
  32. }
  33. else if (filetype == ".css")
  34. {
  35. targetelement = "link";
  36. targetattr = "href";
  37. }
  38. var allsuspects = document.getElementsByTagName(targetelement);
  39. //Search backwards within nodelist for matching elements to remove
  40. for (var i = allsuspects.length; i >= 0; i--)
  41. if (allsuspects[i] &&
  42. allsuspects[i].getAttribute(targetattr) &&
  43. allsuspects[i].getAttribute(targetattr).indexOf(filename) != -1)
  44. allsuspects[i].parentNode.removeChild(allsuspects[i]); //remove element by calling parentNode.removeChild()
  45. }