V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
qhm123
V2EX  ›  问与答

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

  •  
  •   qhm123 · 2012-01-25 11:59:05 +08:00 · 3401 次点击
    这是一个创建于 4487 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我看到phonegap源码中assets/js/phonegap.js.base中的有用到prompt方法,但是这里应该不是弹出提示框的作用,感觉像是和服务器通信,它有这个作用吗?
    2 条回复    1970-01-01 08:00:00 +08:00
    qhm123
        1
    qhm123  
    OP
       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
        2
    qhm123  
    OP
       2012-01-25 12:17:51 +08:00
    与服务器无关,是控制了浏览器也就是WebViewClient处理prompt方法的行为。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1119 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:42 · PVG 06:42 · LAX 15:42 · JFK 18:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.