flask实现鼠标点击监听
启动文件
manage.py
from flask import Flask, render_template, url_for
app = Flask(__name__)
@app.route('/')
@app.route('/button_click')
def button_click():
return render_template('button_click.html')
if __name__ == '__main__':
app.run(debug=True)
HTML文件
<html>
<head><title> Button Click </title></head>
<body>
<div id="example">
</div>
<script type="text/javascript" src=""> </script>
</body>
</html>
js 文件
function printMousePos(event) {
document.body.textContent =
"clientX: " + event.clientX +
" - clientY: " + event.clientY;
}
document.addEventListener("click", printMousePos);
启动之后, 点击屏幕, 出现当前鼠标的坐标
clientX: 93 - clientY: 113