• wap尝试调取app(网易新闻为例)


    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="UTF-8">
    		<title>调起网易新闻app</title>
    		<meta http-equiv="X-UA-Compatible" content="IE=edge">
    		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
    		<meta name="apple-mobile-web-app-capable" content="yes">
    		<meta content="yes" name="apple-touch-fullscreen">
    		<meta name="apple-mobile-web-app-status-bar-style" content="black">
    		<meta name="format-detection" content="telephone=no" />
    
    		<style>
    			a {
    				display: block;
    				 ;
    				text-decoration: none;
    				background-color: #20A0FF;
    				text-align: center;
    				height: 2rem;
    				line-height: 2rem;
    				margin: 3rem auto;
    			}
    		</style>
    	</head>
    
    	<body>
    		<a id="openApp">使用网易新闻客户端打开</a>
    		<script>
    			var s = document.getElementById("openApp");
    			s.onclick = function() {
    				var url = 'newsapp://topic/S1515729142180?s=jiguang&spsug=ug&spsugdate=0&spsugextend=0';
    				testApp(url);
    			}
    			function testApp(url) {
    				var timeout, hasApp = true;
    				var t1 = Date.now();
    				var ifr = document.createElement("iframe");
    				ifr.setAttribute('src', url);
    				ifr.style.display = "none";
    				document.body.appendChild(ifr);
    				timeout = setTimeout(function() {
    					var t2 = Date.now();
    					if(t2 - t1 < 2000) {
    						hasApp = false;
    						if(is_IOS()) {
    							location.href = "http://3g.163.com/links/4633";
    							return;
    						}
    						location.href = "http://3g.163.com/links/4636";
    					}
    				}, 1000);
    
    				location.href = url;
    			}
    			function is_IOS() {
    				var userAgent = 'navigator' in window && 'userAgent' in navigator && navigator.userAgent.toLowerCase() || '';
    				if(/iphone/i.test(userAgent) || /ipad/i.test(userAgent) || /ipod/i.test(userAgent)) {
    					return true
    				} else {
    					return false;
    				};
    			}
    		</script>
    	</body>
    
    </html>
    

      

  • 相关阅读:
    Ping 笔记
    android之RadioGroup
    Android之activity中新建控件
    案例:TableLayout表格布局——迷你计算器
    android中5大布局
    Android体系结构及activity生命周期
    Android之ADB指令
    Android之activity初讲
    简单介绍Android应用特色及详解四大组件
    开发Android应用怎么更改LOGO图标
  • 原文地址:https://www.cnblogs.com/chengyunshen/p/8303680.html
Copyright © 2020-2023  润新知