Javascript 获取UIWebView中“确认”对话框的值

Javascript 获取UIWebView中“确认”对话框的值,javascript,jquery,ios,iphone,uiwebview,Javascript,Jquery,Ios,Iphone,Uiwebview,晚上好, 我们能否检测到UIWebView中加载的网站中出现的确认对话框。如果有人知道如何在UIWebViewDelegate方法中处理。下面给出了我在网站上查看的源文件中编写的代码 <span> <input type="submit" id="cancel" value="Cancel" name="cancel" style="display: none;" /><a href="#" onclick="return Cancel();" tabinde

晚上好,

我们能否检测到UIWebView中加载的网站中出现的确认对话框。如果有人知道如何在
UIWebView
Delegate方法中处理。下面给出了我在网站上查看的源文件中编写的代码

<span>
 <input type="submit" id="cancel" value="Cancel" name="cancel" style="display: none;" /><a
  href="#" onclick="return Cancel();" tabindex="8" class="cancel_link">Cancel</a>
  </span>
 function Cancel() 
 {
    if (confirm('Are you sure you want to exit? Your purchase has not completed. Click Cancel to return to WebPAY. Click OK to return to the merchant site.')) 
     {
        $('#cancel').click();
        return true;
      }
    return false;
 }

函数Cancel()
{
如果(确认('您确定要退出吗?您的购买尚未完成。单击“取消”返回网页。单击“确定”返回商户网站'))
{
$(“#取消”)。单击();
返回true;
}
返回false;
}
如何在
UIWebView
delegate方法中获取值


我需要选中
onclick=“return Cancel();
当它生成确认对话框时,您想从Javascript发送消息,对吗?最简单的方法是从Javascript打开一个带有自定义URL方案的URL。然后在

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
您可以捕获此URL请求并在Cocoa中执行任何您喜欢的操作。如果您想传递参数,也可以在URL请求中发送这些参数

为了简化工作,有一个很好的框架: