h5+app打開pdf,圖片,excel,world(親測可用)

鏈接:https://pan.baidu.com/s/1fGJdDd9yS5A5QZ46ZAytNw
提取碼:gbi9

沒找到在線pdf預覽,按照圖片方式自己替換下路徑
HbuilderX工具打開
真機調試

在這裏插入圖片描述

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title></title>
    <script type="text/javascript">
    	
   		document.addEventListener('plusready', function(){
   			console.log("所有plus api都應該在此事件發生後調用,否則會出現plus is undefined。");
   		});
   		
    </script>
</head>
<body>
	<button type="button">打開pdf</button>
	<button type="button" onclick="openFile('http://img1.imgtn.bdimg.com/it/u=3173584241,3533290860&fm=26&gp=0.jpg')">打開圖片</button>
	<button type="button">打開excel</button>
	<button type="button">打開world</button>
</body>

<script type="text/javascript">
	function openFile(url) {
		//創建一個下載任務
		var dtask = plus.downloader.createDownload(url, {}, function(d, status) {
			if(status == 200) {
				var fileUrl = d.filename;
				plus.runtime.openFile(fileUrl, {}, function(e) {
					alert('打開失敗');
				});
			} else {
				alert("Download failed: " + status);
			}
		});
		dtask.start();
	}
</script>

</html>			
發佈了36 篇原創文章 · 獲贊 14 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章