2016-03-23 177 views

回答

0

那麼我有一個不使用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語句,這只是一個簡單的例子)

+0

謝謝,這工作像一個魅力。發現我最近1小時以來犯的錯誤。 :) – hellboy

+0

嗨@hellboy如果這個或任何答案已經解決了您的問題,請點擊複選標記考慮[接受它](http://meta.stackexchange.com/q/5234/179419)。這向更廣泛的社區表明,您已經找到了解決方案,併爲答覆者和您自己提供了一些聲譽。沒有義務這樣做。 – Bradman175

+0

謝謝@ Bradman175。抱歉造成的不便,我是新的stackoverflow。 :) – hellboy

相關問題