JavaScript in Weebly
Here are some hints how you can use JavaScript in Weebly, There are samples how to write a simple "Click" script and how to call an external PHP Script,
- You can use the built-in JavaScript library that Weebly provides. To access it, click on the “Add Code” button in the Weebly editor and paste your code into the box that appears.
- You can embed JavaScript code directly into your pages using the “Embed Code” element. To use it, click on the “Embed Code” element in the Weebly editor and paste your code into the box that appears.
- You can link an external JavaScript file to your website. To do this, you need to upload the file to your Weebly site editor, then link it to your website using the “Footer Code” section in the settings.
Embed Code Element
In Build Click on Embed Code and paste your code
Simple Click sample:
<button id="myButton">Click Me</button>
<script>
let button = document.getElementById("myButton");
button.addEventListener("click", function() {
alert("Hello World");
});
</script>
Simple Click sample:
<button id="myButton">Click Me</button>
<script>
let button = document.getElementById("myButton");
button.addEventListener("click", function() {
alert("Hello World");
});
</script>
Call a URL "CHATGPT" (Note: it calls a PHP Script without problems with CORS by using window.location.assign)
<button id="open" onclick="callURL()">CHATGPT</button>
<script>
function callURL() {
window.location.assign("https://tagger.biz/chatbot/chatbotclientGuzzle.php/");
}
</script>
Play TIC TAC TOE
<button id="open" onclick="callURL()">TIC TAC TOE</button>
<script>
function callURL() {
window.location.assign("https://playtictactoe.org/");
}
</script>
Tic Tac Toe II
Simple Tic-Tac-Toe Game using JavaScript - GeeksforGeeks
this is a sample for 2 players, copied from GeeksforGeeks.
The sample shows how you can have your script and css on a different location.
It makes your code more readable and more reusable.
this is a sample for 2 players, copied from GeeksforGeeks.
The sample shows how you can have your script and css on a different location.
It makes your code more readable and more reusable.
TIC TAC TOE
Game starts by just Tap on
box
First Player starts as
Player X And Second Player as
Player 0
Bouncing Balls
|
A sample created with AI Assistant in Webstorm
|