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?
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)
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".
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).
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.
Cheers!
jonathanstark
Afraid not, no.
来源:https://stackoverflow.com/questions/2960788/is-it-possible-to-programmatically-change-the-default-search-engine-for-the-ipho