External scripts in Android HTTP server don't work

25 Views Asked by At

I'm trying to make a console joke in HTML, and I have my main script in /system/shell.js and when I put this script into my html <script src="system/shell.js"></script>, when I test it with Simple HTTP server on Android 11, it don't work, but images work

/sh.html

<!--/sh.html-->
<!DOCTYPE html>
<html>
    <head>
        <style>
            body {
                background-color: black;
            }
            p {
                font-family: Monospace;
                color: white;
            }
            button {
                background-color: black;
                border: 5px solid white;
                color: white;
                font-family: Monospace;
            }
        </style>
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
    </head>
    <body>
        <div id="main">
            <form>
                <table>
                    <tr>
                        <td><p>></p></td>
                        <td><input id="console-input" type="text" style="border:none;background-color:black;color:white;font-family:Monospace;"></td>
                        <td><button type="button" onclick="CmdExecute()" id="runBtn">Run</button></td>
                    </tr>
                </table>
            </form>
        </div>
        <script src="shell.js"></script>
    </body>
</html>

/system/shell.js

///system/shell.js

//import { getComArg } from "../lib/console/getArg.js"

const shSystem = {
    "console": {
        "print" : function(text) {
            addElement("p", text);
        }
    }
}

function addElement(tag, text) {
    var element = document.createElement(tag);
    element.textContent = text;
    document.body.appendChild(element);
    console.log("Created element " + tag + " with text " + text);
}

shSystem.console.print("TheShell v.0.0.2")

When I put my scripts like this: <script>//script</script> it works, but I need it to work normal with external scripts

Some info: Tested on Samsung Galaxy A10s (A107F), Chrome 108.0.5359.79, One UI Core 3.1

0

There are 0 best solutions below