我看到phonegap源码中assets/js/phonegap.js.base中的有用到prompt方法,但是这里应该不是弹出提示框的作用,感觉像是和服务器通信,它有这个作用吗?
1
qhm123 OP 自己找到了,DroidGap.java中有hack,重载了WebviewClient的onJsPrompt方法,然后执行了自己的逻辑。
/** * Tell the client to display a prompt dialog to the user. * If the client returns true, WebView will assume that the client will * handle the prompt dialog and call the appropriate JsPromptResult method. * * Since we are hacking prompts for our own purposes, we should not be using them for * this purpose, perhaps we should hack console.log to do this instead! @Override public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) { ... } |
2
qhm123 OP 与服务器无关,是控制了浏览器也就是WebViewClient处理prompt方法的行为。
|