dry18813 2019-05-11 10:13
浏览 84

如何使用PHP隐藏浏览器位置权限弹出窗口?

I've integrated mapmyindia APIs into my website and whenever I reload the page it is showing popup "mywebsite wants to know your location" with allowing and block button options.

If I click block button then it shows another popup "MapmyIndia does not have permission to view your location." which I don't want it to show up. so I want to know how to hide this popup using php code.

I tried:

window.webkitNotifications.hide()
window.PopupNotifications.hide()

I expect the popup to be hidden.

  • 写回答

1条回答 默认 最新

  • douzhi2988 2019-05-11 12:46
    关注

    I fear there is a lot of misunderstanding on your part.

    First of all, PHP is a backend language, meaning it runs on the server and not on the client (= the browser). PHP (with the CodeIgniter framework) is actually used to generate HTML page containing CSS and JavaScript. Hence why PHP can't interact directly with the browser.

    JavaScript is the programming language of the frontend, which run directly on the client (the browser) and directly interact with the user.

    Indeed, the 2 lines of code you said you tried are JavaScript code.

    So the question would rather be "how to hide browser location permission popup using JavaScript?"

    And here is another misunderstanding : luckily, you simply can't. And that's actually good.

    When asking for geolocation, any browser will automatically ask user permission to do so. The only thing you can do is wait, hope they accept, and handle the case when they refuse.

    There is this good article from MDN explaining why permission are needed, and how they are implemented.

    Websites can already track us enough as it is on the web, thanks goodness they can't just get our exact GPS coordinate without asking our permission.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!