1. 获悉IOS应用的CFBundleURLSchemes(plist文件里面含有)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLName</key> <string>com.fanxer.crazylottery</string> <key>CFBundleURLSchemes</key> <array> <string>demo</string> </array> </dict> </array> </plist>
2. javascript的使用
<script type="text/javascript"> var id; function reback(status){ window.location.href = "demo:"+status; if (id != undefined) { window.clearTimeout(id); } id = window.setTimeout('windowclose()',3000); } function windowclose(){ window.open('','_self'); window.close(); } </script>
业务需求是,跳回demo应用后,3秒钟后关闭当前页面
3秒退出,解决ios 8.1.1直接关闭,不执行跳转到应用功能
ios 8.1.0 不支持window.close()方法,所有无效
3. demo页面
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html> <head> <title>demo</title> <meta http-equiv="Content-Type" name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0;charset=utf-8;application/vnd.wap.xhtml+xml" /> <meta HTTP-EQUIV="pragma" CONTENT="no-cache"/> <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"/> <meta HTTP-EQUIV="expires" CONTENT="0"/> </head> <script type="text/javascript"> var id; function reback(status){ window.location.href = "demo:"+status; if (id != undefined) { window.clearTimeout(id); } id = window.setTimeout('windowclose()',3000); } function windowclose(){ window.open('','_self'); window.close(); } </script> <style type="text/css"> @media not screen and (orientation:portrait){ body{color:#f00;} } body,div,p,form{ padding:0; margin:0; font-size:18px; } .tip-title{ font-size:22px; font-weight:100; } .font-lottery-type{ font-size:25px; font-weight:100; margin-bottom:17px; } .font-18{ font-size:18px; font-weight:100; margin-bottom:10px; } .font-20{ font-size:20px; font-weight:100; } body{ padding: 5px 0 2px 0; line-height:20px; } img{ border:none; vertical-align:-20%; } strong{ font-weight:bolder; } a{ color:#0077FF; text-decoration:underline; } a:hover{ color:#ffffff; background-color:#3796FF; } input[type="submit"], input[type="reset"], input[type="button"], button { -webkit-appearance: none;} .ap-noline{ line-height:14px; } .ap-c-black{ color:#000000; } .ap-c-gray{ color:#999999; } .ap-c-orange{ color:#ff9900; } .ap-c-red{ color:#ff0033; } .ap-c-green{ color:#00CC00; } .ap-cb-gray{ background-color:#F2F2F2;; } .ap-cb-red{ background-color:#9a0000; } .ap-a{ color:#ffffff; line-height:36px; padding:4px; height:36px; } .ap-b{ color:#000000; line-height:16px; padding:4px; } .b-hr{ border-top:1px solid #AEAEAE; } .ap-hr{ border-bottom:1px solid #AEAEAE; } input.checkbox,input[type=checkbox],input[type=radio]{ padding:0; margin-right:4px; cursor:pointer; vertical-align:middle; vertical-align:-20%; } .ap-left{ margin-left: 5px; line-height:18px; } .ap-top{ // border:1px solid #000000; // margin-left: 2px; height:100%; width:320px; } .btn{ font-size:18px; width:140px; height:36px; background-color:#9a0000; color:#ffffff; border:0; } .title-po{ position: relative; top: -20%; } </style> <body> <div align="center"> <div class="ap-top" style="text-align:left;"> <div class="ap-a ap-hr ap-cb-red tip-title" align="center"> Demo例子 </div> <div class="ap-b ap-left ap-noline" style="height:70px;vertical-align:middle;text-align:position;" > <span class="ap-c-green font-lottery-type title-po" >欢迎您使用,Demo例子</span><br /> </div> <div class="b-hr" /> <div class="ap-b ap-left ap-noline"> <br /> Demo test<br /><br /> <span class="ap-c-green"></span><br /> <div align="center"> <span align="center"> <input type="button" value="返回Demo" onclick="javascript:reback(1);" class="btn" style="background-color:#d9d9d9;border:1px solid #aaaaaa;color:#333333" /> </span> <span align="center"> <input type="button" value="继续Demo的某个页" class="btn" onclick="javascript:reback(2);" /> </span><br/> </div> </div> </div> </div> </body> </html>
扫描二维码关注公众号,回复:
525954 查看本文章