Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:24:08+00:00 2026-06-02T20:24:08+00:00

I am creating a html-only(no server sided code) website that supposed to have multiple

  • 0

I am creating a html-only(no server sided code) website that supposed to have multiple themes,

Wherein user can select/change a theme to view the website.

Can you suggest some concepts on how to do this or at least point me into some helpful articles.

Thank you for your help in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:24:09+00:00Added an answer on June 2, 2026 at 8:24 pm

    Probably overkill… but here is a font selector example I came up with using Google Font API and a Document Fragment Builder script I wrote a while ago.

    var FragBuilder = (function() {
        var applyStyles = function(element, style_object) {
            for (var prop in style_object) {
                element.style[prop] = style_object[prop];
            }
        };
        var generateFragmentFromJSON = function(json) {
            var tree = document.createDocumentFragment();
            json.forEach(function(obj) {
                if (!('tagName' in obj) && 'textContent' in obj) {
                    tree.appendChild(document.createTextNode(obj['textContent']));
                } else if ('tagName' in obj) {
                    var el = document.createElement(obj.tagName);
                    delete obj.tagName;
                    for (part in obj) {
                        var val = obj[part];
                        switch (part) {
                        case ('textContent'):
                            el.appendChild(document.createTextNode(val));
                            break;
                        case ('style'):
                            applyStyles(el, val);
                            break;
                        case ('childNodes'):
                            el.appendChild(generateFragmentFromJSON(val));
                            break;
                        default:
                            if (part in el) {
                                el[part] = val;
                            }
                            break;
                        }
                    }
                    tree.appendChild(el);
                } else {
                    throw "Error: Malformed JSON Fragment";
                }
            });
            return tree;
        };
        var generateFragmentFromString = function(HTMLstring) {
            var div = document.createElement("div"),
                tree = document.createDocumentFragment();
            div.innerHTML = HTMLstring;
            while (div.hasChildNodes()) {
                tree.appendChild(div.firstChild);
            }
            return tree;
        };
        return function(fragment) {
            if (typeof fragment === 'string') {
                return generateFragmentFromString(fragment);
            } else {
                return generateFragmentFromJSON(fragment);
            }
        };
    }());
    
    function jsonp(url) {
        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = url;
        document.getElementsByTagName('body')[0].appendChild(script);
    }
    
    function replacestyle(url) {
        if (!document.getElementById('style_tag')) {
            var style_tag = document.createElement('link');
            style_tag.rel = 'stylesheet';
            style_tag.id = 'style_tag';
            style_tag.type = 'text/css';
            document.getElementsByTagName('head')[0].appendChild(style_tag);
            replacestyle(url);
        }
        document.getElementById('style_tag').href = url;
    }
    
    function loadFonts(json) {
        var select_frag = [
            {
            'tagName': 'select',
            'id': 'font-selection',
            'childNodes': [
                {
                'tagName': 'option',
                'value': 'default',
                'textContent': 'Default'}
            ]}
        ];
        json['items'].forEach(function(item) {
            var family_name = item.family,
                value = family_name.replace(/ /g, '+');
    
            if (item.variants.length > 0) {
                item.variants.forEach(function(variant) {
                    value += ':' + variant;
                });
            }
    
            select_frag[0].childNodes.push({
                'tagName': 'option',
                'value': value,
                'textContent': family_name
            });
        });
    
        document.getElementById('container').appendChild(FragBuilder(select_frag));
        document.getElementById('font-selection').onchange = function(e) {
            var font = this.options[this.selectedIndex].value,
                name = this.options[this.selectedIndex].textContent;
            if (font === 'default') {
                document.getElementById('sink').style.fontFamily = 'inherit';
            } else {
                document.getElementById('sink').style.fontFamily = name;
                replacestyle('https://fonts.googleapis.com/css?family=' + font);
            }
        };
    }
    
    jsonp("https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyDBzzPRqWl2eU_pBMDr_8mo1TbJgDkgst4&sort=trending&callback=loadFonts");​
    

    Here is the Kitchen Sink example…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a demo that must be in html code only (no server side
I have a website that right now, runs by creating static html pages from
I have a scenario that, I am creating dynamic html content and I need
I am creating a chunk of HTML/JavaScript with the below code: $result = mysql_query(SELECT
When you are creating a Search for your Website, you Want the user experience
Is there a way that I can Programmatically set an Expires Header in code
I am creating a form using only HTML and JavaScript where I want to
At work, we stumbled upon Bugzilla creating HTML output that led to lines much
I am dynamically creating an HTML table by using a repeater. I have four
I'm creating an app that has to input/output data from a specific web server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.