Ignore:
Timestamp:
2022-08-14T17:29:18+12:00 (21 months ago)
Author:
anupama
Message:

Updates to the GS3 style-e collection, with the new styles and changed the javascript so it's better suited for switching between styles without breaking too much.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documented-examples/trunk/style-e/script/custom-script.js

    r36370 r36371  
     1function 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
    127// This function copied from extra.dm of style-e DEC collection
    228// It changes the current stylesheet to the named one of parameter
    329function SetStyle(stylename) {
     30    //alert("In custom-sript.js::SetStyle()");
    431  var body = document.getElementsByTagName('body')[0];
    532  body.style.backgroundImage = "";
     
    1542  }
    1643}
     44
Note: See TracChangeset for help on using the changeset viewer.