我使用以下代码在 HTML 页面中显示 PDF 文件列表。我想将每个 PDF 文件的第一页显示为它们的图像图标。到目前为止,我没有使用任何服务器。请指导我。代码在这里:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link type="text/css" href="cssjquery/ui-lightness/jquery-ui-1.8.24.custom.css" rel="stylesheet" />
<title>Unit 3, ADS</title>
<style type="text/css">
.imagewrap {
display: inline-block;
position: relative;
}
.btn {
position: absolute;
top: 0;
right: 0;
}
</style>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript" src="jsjquery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="jsjquery/jquery-ui-1.8.24.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('a.btn').on('click',function(e){
e.preventDefault();
pdfID = $(this).closest('.imagewrap')[0].id;
$('#dialog').dialog('open');
alert('Deleting '+pdfID+'');
$(this).closest('.imagewrap')
.fadeTo(300,0,function(){
$(this)
.animate({width:0},200,function(){
$(this)
.remove();
});
});
});
});
</script>
</head>
<body>
<h1>PDF Files</h1>
<br><br>
<div class="imagewrap" id="pdf1">
<a href="something1.pdf"><img src="pdf icon.jpg" width="100" height="100" border="0"></a> <a class="btn" href="#"><i class=" icon-remove-sign" ></i></a>
</div>
<div class="imagewrap" id="pdf2">
<a href="something2.pdf"><img src="pdf icon.jpg" width="100" height="100" border="0"></a> <a class="btn" href="#"><i class=" icon-remove-sign" ></i></a>
</div>
<div class="imagewrap" id="pdf3">
<a href="something3.pdf"><img src="pdf icon.jpg" width="100" height="100" border="0"></a> <a class="btn" href="#"><i class=" icon-remove-sign" ></i></a>
</div>
</body>
PS:我在这里为每个 div 添加了 imagewrap 类,因为否则我无法将删除图标添加到每个 pdf 图标图像中。
任何帮助将不胜感激。提前致谢