dourong8495 2018-01-30 00:48
浏览 161

当用户代理来自webview android app时,如何隐藏网站标题(div)?

Im working off of an app template that creates a webview for my site. I need a way to hide a div depending on whether of not that user is using my webview android app.

So far I have found the following php code:

if ($_SERVER['HTTP_X_REQUESTED_WITH'] == "com.company.app") {
    echo 'WebView';
} else{
    echo 'Not WebView';
}

With this code what else do I need to add in order to hide a specific div (my header in this case)?

  • 写回答

1条回答 默认 最新

  • dongraa1986 2018-01-30 01:04
    关注

    I would recomend using the open source library made available at mobiledetect.net. You can then use their 'magic methods' to determine if your user is on android.

    if( $detect->isAndroidOS() ){ }else{ }

    From there it's as simple as placing your <div> inside the else, or applying the style to hide your <div>(<style>.divsClass{display:none;}</style>), or by loading an additional JS or CSS file. There are a lot of variations on how... and depending on your specific scenario, the best option might change.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度