js的prompt有和服务器通信的作用吗?

2012-01-25 11:59:05 +08:00
 qhm123
我看到phonegap源码中assets/js/phonegap.js.base中的有用到prompt方法,但是这里应该不是弹出提示框的作用,感觉像是和服务器通信,它有这个作用吗?
3418 次点击
所在节点    问与答
2 条回复
qhm123
2012-01-25 12:14:33 +08:00
自己找到了,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) {

...
}
qhm123
2012-01-25 12:17:51 +08:00
与服务器无关,是控制了浏览器也就是WebViewClient处理prompt方法的行为。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/26045

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX