最近做一個h5的落地頁,用戶輸完信息后,去下載app,這里切記幾個知識點
1.在微信和QQ中是不能下載app的,需要跳到瀏覽器中去下載。
2.window.location.href和window.open鏈接到app的鏈接是行不通的,在webview中會斃掉(h5嵌在第三方的貸超app中就會掛掉)。需要使用a標簽 href鏈接url
3.判斷微信,qq,qq瀏覽器,微信好搞,
function isWx() { var ua = navigator.userAgent.toLowerCase(); return !!ua.match(/MicroMessenger/i); }
qq我之前是這樣子判斷
function isQQ() { var ua = navigator.userAgent.toLowerCase(); return !!ua.match(/mqqbrowser|qzone|qqbrowser/i); }
其實是不對的,這樣就會qq和qq瀏覽器都符合條件,然后就對比qq和qq瀏覽器的區別
function isQQ() { var ua = navigator.userAgent.toLowerCase(); return !!ua.match(/ qq\//i); //qq的userAgent的前面有個空格,后面有個斜桿 }
這樣子就能區分qq和qq瀏覽器了,歡迎補充好的方法!
