我正在尝试制作一个Web应用程序,我将在其中渲染一些pdf对象。我想检测 pdf 容器内的点击位置。OnClick 事件不起作用。如何进行?
好吧,我有一个不使用jquery的例子。
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div onmousedown="action()">
<object data="http://www.polyu.edu.hk/iaee/files/pdf-sample.pdf" type="application/pdf" style="width: 500px; height: 500px;"></object>
</div>
<p>click around the top and the bottom of the pdf for some text to display and change below this.</p>
<p id="texttyy"></p>
<p id="posy"></p>
<script>
function action() {
var x = event.clientX;
var y = event.clientY;
var cood = "(" + x + ", " + y + ")"
if (y < 250) {
document.getElementById("texttyy").innerHTML = "yes";
} else {
document.getElementById("texttyy").innerHTML = "no";
}
document.getElementById("posy").innerHTML = cood;
}
</script>
</body>
</html>
这会与您想要的相似吗?我不知道你想如何显示pdf文件,所以我只是假设。(你应该修改if语句,这只是一个简单的例子)