1. 程式人生 > 其它 >H5微信開啟後引導使用者去瀏覽器

H5微信開啟後引導使用者去瀏覽器

技術標籤:微信小程式小程式

效果圖

素材1+素材2

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <
script
src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js">
</script> <title>H5引導頁</title> </head> <style> * { padding: 0; margin: 0; } body { width: 100%; height: 100%; background: #FFFFFF; } .bg
{ display: none; position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 10; background: rgba(0, 0, 0, 0.9); text-align: end; overflow: hidden; padding: 1rem 5px 0 1rem; } .bg img { width: 93%;
height: auto; }
</style> <body> <div class="app"> <div class="bg"><img src="https://img.796t.com/res/2020/12-17/20/5b15117f54f5fb0ec3d92a2339d3bd4a.png" alt=""></div> <h2>內容</h2> </div> <script> window.onload = function() { var fontSize = $(window).width() / 18.75; //螢幕的寬 $("html").css("font-size", fontSize + "px"); if (IsWeixinOrAlipay() == 13) { $(".bg").css('display', 'block') } else { console.log(IsWeixinOrAlipay()) } } function IsWeixinOrAlipay() { var ua = window.navigator.userAgent.toLowerCase(); //判斷是不是微信 if (ua.match(/MicroMessenger/i) == 'micromessenger') { return 13; } //判斷是不是支付寶 if (ua.match(/AlipayClient/i) == 'alipayclient') { return 12; } //哪個都不是 return 0; } </script> </body> </html>