一 . 思路:
1. android 使用webview加载网页, 在 android 端设置其 useragent 特定字符
2. 服务器端 php 判断获取的 user agent 中有没有 android 给的特定字符
3. 如果有, 则为 android webview加载网页
二 . 代码
android 端需要设置:
(这两句代码: 找到android端的useragent, 将其中的android 字符串改为 app_webview android , app_webview 就是给php的标志)
string useragent = webview.getsettings().getuseragentstring();//找到webview的useragentwebview.getsettings().setuseragentstring(useragent.replace(android, app_webview android));//在useragent上添加app_webview 标识符,服务器会获取该标识符进行判断
php服务器端:
三. 说明
如果是ios的话 , php端代码判断也是一样的 , 只需要在ios端把 useragent 中添加 “app_webview “字符串即可
').addclass('pre-numbering').hide(); $(this).addclass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadein(1700); }); }); 以上就介绍了 php判断网页 是否是 android webview加载,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
