吳孟雯Javascript在瀏覽器可以執行不需要VS Code
Javascript在網頁就可以執行不需要開啟VS Code
以上程式碼
<STYLE>BUTTON{BORDER:GREEN 5PX SOLID;BORDER-RADIUS:30PX;}</STYLE><h1>Javascript在網頁就可以執行不需要開啟VS Code</h1>
<button onclick="LH()">王佳螢執行</button>
<button onclick="LK()">王佳螢執行</button>
<canvas height="400" id="my" style="background: black;" width="1200"></canvas>
<script>
function LH()
{
var c = document.getElementById("my");
var cty = c.getContext("2d");
var x = 0;
var y = 200;
var h = 200;
cty.beginPath();
cty.lineWidth = 5;
cty.moveTo(x,y);
while (x < 1000){
x = x + 1;
y = 200 - h * Math.sin(0.02*x);
cty.lineTo(x, y);
cty.strokeStyle = "yellow";
cty.stroke();
};
}
function LK()
{
var c = document.getElementById("my");
var cty = c.getContext("2d");
var x = 0;
var y = 0;
var h = 200;
cty.beginPath();
cty.lineWidth = 5;
cty.moveTo(x,y);
while (x < 1000){
x = x + 1;
y = 200 - h * Math.cos(0.02*x);
cty.lineTo(x, y);
cty.strokeStyle = "white";
cty.stroke();
};
}
</script>
期末考,為何拷貝吳孟雯?https://mengwenpython.blogspot.com/2026/01/javascriptvs-code.html
回覆刪除