Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

script has div ? or a bug to fix it #do; script close script than div

A topic by investus.itch.io created 29 days ago Views: 105 Replies: 3
Viewing posts 1 to 3
(3 edits)
I.setup_layout()</script><script type="text/template" id="loading_lightbox_tpl"><div aria-live="polite" class="lightbox loading_lightbox"><div class="loader_outer"><div class="loader_label">Loading</div><div class="loader_bar"><div class="loader_bar_slider"></div></div></div></div></script><script type="text/javascript">init_HtmlEmbed

#link-url-source: view-source:https://investus.itch.io/grid-based-movement-controller-signs-walker-3d

I.setup_layout();</script><script type="text/template" id="loading_lightbox_tpl"></script><div aria-live="polite" class="lightbox loading_lightbox"><div class="loader_outer"><div class="loader_label">Loading</div><div class="loader_bar"><div class="loader_bar_slider"></div></div></div></div><script type="text/javascript">init_HtmlEmbed

#link-url-1M-to-fix: https://investus.itch.io/grid-based-movement-controller-signs-walker-3d

Admin (1 edit)

Script tags can be used to hold text data if you set the type to something other than javascript. They will not be executed by the browser. In this case, our loading lightbox dialog template is stored in a script tag before being displayed to the user.

I.setup_layout() //than add ; because everywhere else javascript commands are closed ;

(3 edits)

Using HTML <template> Element = is modern compatible but also great to code editors.
The <template> element is a built-in HTML feature designed specifically for including template markup.

  • Content inside the <template> tag is not rendered when the page loads, but can be manipulated by JavaScript, * like doing here:
<template id="loadingLightboxTemplate">
    <div class="lightbox loading_lightbox" style="display: none;">
        <div class="loader_outer">
            <div class="loader_label">Loading</div>
            <div class="loader_bar">
                <div class="loader_bar_slider"></div>
            </div>
        </div>
    </div>
</template>

<script>
    let eventsToListen = ['DOMContentLoaded', 'load'], eventsSet = new Set(),
        handleEvent = (e) => {
            eventsSet.add(e.type);
            window.removeEventListener(e.type, handleEvent);
            eventsToListen = eventsToListen.filter(event => event !== e.type);

            if (eventsSet.size === 2) {
                let lb = document.importNode(document.getElementById("loadingLightboxTemplate").content, true).firstChild;
                document.body.appendChild(lb).style.display = 'flex';

                setTimeout(() => {
                    lb.remove();
                    eventsSet.clear(); 
                    eventsSet = null; // Clean up eventsSet
                    lb = null; // Clean up lb
                    handleEvent = null; // Clean up handleEvent function
                    eventsToListen = null; // Clean up eventsToListen array
                }, 1000);
            }
        };

    eventsToListen.forEach(event => window.addEventListener(event, handleEvent));
</script>