webview/webview_go

Loading scripts and styles from files inside <script> and <link>

YairLevi opened this issue · 0 comments

pretty straight forward. I have the following HTML:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #root {
            max-width: 1280px;
            margin: 0 auto;
            padding: 2rem;
            text-align: center;
            background-color: #1f1f0f;
        }
    </style>
</head>
<body>
<div id="root">
    <p id="item"></p>
    <button>yes</button>
</div>
<script>
    document.getElementById("item").innerHTML = "generated content"
</script>
</body>
</html>

The output window is working as expected, showing the styles and the generated text inside the <p> tag.

however, if the script and styles were in files like this:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="module" src="index.js"></script>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="root">
    <p id="item"></p>
    <button>yes</button>
</div>
</body>
</html>

Both the script and styles do not take effect. couldn't find a solution or anyone talking about it.
is there a solution? thanks in advance.

I am on windows 10, go 1.20