Discussion:
<a href="javascript:main();"> does not work
(Wiadomość utworzona zbyt dawno temu. Odpowiedź niemożliwa.)
Jivanmukta
2023-07-10 07:12:21 UTC
Permalink
In index.html file I have:

<body>

<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="javascript:main();">Tron Game</a>
<button class="navbar-toggler" type="button" data-toggle="collapse"
data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto" id="score-list">
</ul>
</div>
</nav>

<main role="main" class="container-fluid">
<div class="game-container">
<canvas id="myCanvas" width=600 height=600 style="border:2px
solid #eee;">
</canvas>
</div>
</main>
<!-- /.container -->

<script src="./index.js"></script>

</body>

File index.js contains many functions, for example main(). I want to
have main() called when user clicks on Tron Game text.
The solution above does not work, nothing happends when Tron Game link
is clicked.
zpksoft
2023-07-10 15:44:57 UTC
Permalink
Post by Jivanmukta
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="javascript:main();">Tron Game</a>
try:

<a class="navbar-brand" href="#" onclick="main();">Tron Game</a>

Paweł

Loading...