Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

My javascript file just isn't working when I point to it in html

this is the html, it points to a javascript file

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Fund me app</title>
</head>

<body>
    penis
    <script src="./index.js" type="text.javascript">
        

    </script>
    <button id="connectButton" onclick="connect()"> Connect

    </button>
</body>

</html>

this is index.js I’ve pointed the html code to it, but it just doesn’t run

async function connect() {
    if (typeof window.ethereum !== "undefinied") {
        await window.ethereum.request({ method: "eth_requestAccounts" })
        document.getElementById("connectButton").innerHTML = "Connected"
    } else {
        document.getElementById("connectButton").innerHTML = "Please install metamask"
    }
}

When I click on a button, it should run the javascript code – but it doesn’t. Nothing happens?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The type attribute of the script tag should be text/javascript, not text.javascript.

<script src="./index.js" type="text/javascript"></script>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading