gpt4 book ai didi

javascript - 如何检测 HTML 中 pdf 对象的点击事件

转载 作者:行者123 更新时间:2023-11-28 06:13:28 25 4
gpt4 key购买 nike

我正在尝试制作一个网络应用程序,我将在其中渲染一些 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语句,这只是一个简单的例子)

关于javascript - 如何检测 HTML 中 pdf 对象的点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36168933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com