码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2018-01-17 18:09:49      阅读:697      评论:0      收藏:0      [点我收藏+]

标签:mob   turn   viewport   one   mat   ipa   maximum   utf-8   tor   

<!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;
				width: ;
				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>

  

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

标签:mob   turn   viewport   one   mat   ipa   maximum   utf-8   tor   

原文地址:https://www.cnblogs.com/chengyunshen/p/8303680.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!