是否可以通过编程方式更改Iphone的默认搜索引擎? [英] Is it possible to programmatically change the default search engine for the Iphone?
问题描述
我们想要构建一个网页,该网页请求iphone用户更改其默认搜索提供程序的权限.通过移动浏览器可以做到这一点吗?
We want to build a webpage that requests permissions from an iphone user to change their default search provider. Is this possible with through mobile safari?
推荐答案
iOS上的Mobile Safari中的Window对象似乎具有三个未公开的功能,这些功能可以与默认搜索引擎进行交互:
The Window object in Mobile Safari on iOS has what appear to be three undocumented functions that make interaction with the default search engine possible:
window.canSetSearchEngine()
window.getSearchEngine()
window.setSearchEngine(string)
Yahoo移动搜索网站使用这些功能抛出一个(非常烦人的)对话框询问您想要吗将您的默认搜索引擎更改为Yahoo?y/n".
The Yahoo mobile search site uses these functions to throw a (very annoying) dialog box asking "Would you like to change your default search engine to Yahoo? y/n".
我尚未能够使setSearchEngine()
函数正常工作,因为出于某些原因,我没有这样做的权限(即canSetSearchEngine()
返回false).
I haven't yet been able to make the setSearchEngine()
function work because for some reason I don't have permission to do so (i.e., canSetSearchEngine()
returns false).
我知道Yahoo代码可以工作,因此看来必须可行.我想知道js文件是否必须托管在与所选搜索引擎相关的白名单域中. IOW-也许只有从yahoo,google或bing域提供的js代码才有权调用setSearchEngine()
函数.
I know the Yahoo code works so it appears that it must be possible to do. I wonder if the js file has to be hosted on a whitelisted domain related to the selected search engine. IOW - perhaps only js code served from a yahoo, google, or bing domain has permission to call the setSearchEngine()
function.
干杯!
乔纳森·斯塔克
这篇关于是否可以通过编程方式更改Iphone的默认搜索引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!