@@ -195,16 +195,37 @@ function PdfLoader(pdf, Sop) {
195
195
img2darkByClass ( "pdf" , false ) ;
196
196
leftLayout . setAccent ( Sop . parent . SeriesInstanceUID ) ;
197
197
198
- if ( getByid ( "PDFView" ) ) {
199
- if ( getByid ( "PDFView" ) . src != pdf )
200
- getByid ( "PDFView" ) . src = pdf ;
201
- }
202
- else {
203
- var iFrame = document . createElement ( "iframe" ) ;
204
- iFrame . className = "PDFView" ;
205
- iFrame . id = "PDFView" ;
206
- iFrame . src = pdf ;
207
- getByid ( "PdfPage" ) . appendChild ( iFrame ) ;
198
+ //如果瀏覽器支援顯示pdf
199
+ if ( 'PDF Viewer' in navigator . plugins ) {
200
+ if ( getByid ( "PDFView" ) ) {
201
+ if ( getByid ( "PDFView" ) . src != pdf )
202
+ getByid ( "PDFView" ) . src = pdf ;
203
+ }
204
+ else {
205
+ var iFrame = document . createElement ( "iframe" ) ;
206
+ iFrame . className = "PDFView" ;
207
+ iFrame . id = "PDFView" ;
208
+ iFrame . src = pdf ;
209
+ getByid ( "PdfPage" ) . appendChild ( iFrame ) ;
210
+ }
211
+ } else {
212
+ if ( getByid ( "PDFDownloadImg" ) ) {
213
+ if ( getByid ( "PDFDownloadImg" ) . pdf != pdf )
214
+ getByid ( "PDFDownloadImg" ) . pdf = pdf ;
215
+ } else {
216
+ var img = new Image ( ) ;
217
+ img . id = "PDFDownloadImg" ;
218
+ img . width = 100 , img . height = 100 ;
219
+ img . src = "../image/icon/lite/download_pdf.png" ;
220
+ img . pdf = pdf ;
221
+ img . onclick = function ( ) {
222
+ var link = document . createElement ( 'a' ) ;
223
+ link . href = this . pdf ;
224
+ link . download = 'file.pdf' ;
225
+ link . dispatchEvent ( new MouseEvent ( 'click' ) ) ;
226
+ }
227
+ getByid ( "PdfPage" ) . appendChild ( img ) ;
228
+ }
208
229
}
209
230
}
210
231
0 commit comments