如何检测页面上的链接的PDF,并显示消息使用jquery下载Adobe reader? [英] How to detect linked PDF on a page and show message to download Adobe reader using jquery?
本文介绍了如何检测页面上的链接的PDF,并显示消息使用jquery下载Adobe reader?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果网页连结了.pdf档案,则 #mainontent $>之前应该在
< p>
c $ c> div作为最后一个段落< p>
If page has .pdf files linked then a message in <p>
should be add just before end of the #mainontent
div as a last paragraph <p>
p>
for example this is default html?
<div id="maincontent">
<ul class="cheat_sheet_downloads">
<li><a href="http://www.addedbytes.com/download/css-cheat-sheet-v2.pdf">PDF, 316Kb</a></li>
<li><a href="http://www.addedbytes.com/download/css-cheat-sheet-v3.pdf/">PNG, 77Kb</a></li>
</ul>
<div>
检测到pdf之后
像这样
<div id="maincontent">
<ul class="cheat_sheet_downloads">
<li><a href="http://www.addedbytes.com/download/css-cheat-sheet-v2.pdf/">PDF, 316Kb</a></li>
<li><a href="http://www.addedbytes.com/download/css-cheat-sheet-v3.pdf/">PNG, 77Kb</a></li>
</ul>
<div>
<div id="ttip">
Most computers will open PDF documents automatically, but you may need to
download <a title="Link to Adobe website - opens in a new window"
href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank">
Adobe Reader</a>.
</div>
或作为 #maincontent
div后的另一个div 。可以用jquery吗?
or as another div after #maincontent
div. Is it possible with jquery?
编辑:
页面可以有一个或多个PDF我想添加消息在底部。我需要IE 6兼容性
Page can have one or more PDF i want to add message at bottom. and i need IE 6 compatibility too
编辑2:我不能,不想使用鼠标工具提示
Edit 2 : I can't and don't want to use mouse over tooltip
推荐答案
var tip = "<p>Most computers will open PDF documents ";
tip += "automatically, but you may";
tip += "need to download <a title='Link to Adobe website-opens in a new window'";
tip +=" href='http://www.adobe.com/products/acrobat/readstep2.html'
target='_blank'>Adobe Reader</a>.</p>";
$(document).ready(function(){
//IF NUMBER OF PDF LINKS IS MORE THAN ZERO INSIDE DIV WITH ID maincontent
//THEN THIS WILL PUT TIP PARAGRAPH AS LAST CHILD OF DIV
if($("div#maincontent a[href*='/pdf']").length>0){
$("div#maincontent").children(":last-child").after(tip);
}
});
检查这里
这篇关于如何检测页面上的链接的PDF,并显示消息使用jquery下载Adobe reader?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文