簡體   English   中英

獲取UIWebView中的確認對話框的值

[英]get the value of confirm dialog box in UIWebView

晚上好,

我們能否檢測到出現在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;
 }

如何獲取UIWebView委托方法中的值?

我需要檢查onclick="return Cancel();在生成確認對話框的位置

所以您想通過Javascript向Cocoa發送消息,對嗎? 最簡單的方法是使用Javascript中的自定義URL方案打開URL。 然后在

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

您可以捕獲此URL請求,並在Cocoa中做任何您想做的事情。 如果要傳遞參數,也可以在URL請求中一起發送。

為了使事情變得容易,有一個很好的框架: https : //github.com/ochameau/NativeBridge

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM