问题
I want to run a function to open the link in the android browser system. Here is an illustration of my questions. See the illustration What should I do? I only use javascript not java. Please help
回答1:
Some time ago I encountered the same problem. To do this I modified the InAppBrowser source code. you should override the shouldOverrideUrlLoading method in the InAppBrowserClient class found in InAppBrowser.java
This will allow you to hook in to the request before the url is being loaded and choose an alternate behavior. In your case loading the URL in the system browser.
Your code will look something like this:
@Override
public boolean shouldOverrideUrlLoading (WebView view, String url){
if(url.equals("Your URL to be loaded")){
openExternal(url);
return true;
}
return false;
}
来源:https://stackoverflow.com/questions/27718204/how-do-i-run-a-function-cordova-if-the-command-embedded-in-external-sites