- Timestamp:
- 2022-08-14T17:29:18+12:00 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documented-examples/trunk/style-e/script/custom-script.js
r36370 r36371 1 function replaceStyle(stylesheet) { 2 //alert("In custom-sript.js::ReplaceStyle()"); 3 var body = document.getElementsByTagName('body')[0]; 4 var linkEl = document.getElementById("custom-style"); 5 var href = linkEl.getAttribute("href"); 6 var lastSlashIndex = href.lastIndexOf("/"); 7 var hrefPrefix = href.substring(0, lastSlashIndex); 8 9 href = hrefPrefix + "/" + stylesheet + ".css"; 10 linkEl.setAttribute("href", href); 11 12 13 // https://techstacker.com/how-to-remove-all-css-from-site-with-javascript/ 14 if(stylesheet == "") { /* gs3-style-red */ 15 document 16 .querySelectorAll('style,link[rel="stylesheet"]') 17 .forEach(item => item.remove()) 18 19 // https://code-boxx.com/dynamically-load-replace-css/ 20 //document.head.appendChild(linkEl); 21 } 22 23 //reloadCss(); // https://stackoverflow.com/questions/2024486/is-there-an-easy-way-to-reload-css-without-reloading-the-page 24 } 25 26 1 27 // This function copied from extra.dm of style-e DEC collection 2 28 // It changes the current stylesheet to the named one of parameter 3 29 function SetStyle(stylename) { 30 //alert("In custom-sript.js::SetStyle()"); 4 31 var body = document.getElementsByTagName('body')[0]; 5 32 body.style.backgroundImage = ""; … … 15 42 } 16 43 } 44
Note:
See TracChangeset
for help on using the changeset viewer.