我需要从一个绿色按钮获取我的JavaScript代码,当用鼠标单击该按钮时,它会通过警报功能转到另一页,它需要是本地文件,而不是随机网站!这是我的代码片段,只需要有关如何重写的帮助!
//Add event listener to canvas element
canvas.addEventListener('click', unction(event) {
//Control that click event occurred within position of button
//NOTE: This assumes canvas is positioned at top left corner
if (
event.x > buttonX &&
event.x < buttonX + buttonW &&
event.y > buttonY &&
event.y < buttonY + buttonH
) {
//Executes if button was clicked!
alert('Button was clicked!');
}