• <tfoot id='eLFKk'></tfoot>
    • <bdo id='eLFKk'></bdo><ul id='eLFKk'></ul>
  • <small id='eLFKk'></small><noframes id='eLFKk'>

    <legend id='eLFKk'><style id='eLFKk'><dir id='eLFKk'><q id='eLFKk'></q></dir></style></legend>

      <i id='eLFKk'><tr id='eLFKk'><dt id='eLFKk'><q id='eLFKk'><span id='eLFKk'><b id='eLFKk'><form id='eLFKk'><ins id='eLFKk'></ins><ul id='eLFKk'></ul><sub id='eLFKk'></sub></form><legend id='eLFKk'></legend><bdo id='eLFKk'><pre id='eLFKk'><center id='eLFKk'></center></pre></bdo></b><th id='eLFKk'></th></span></q></dt></tr></i><div id='eLFKk'><tfoot id='eLFKk'></tfoot><dl id='eLFKk'><fieldset id='eLFKk'></fieldset></dl></div>

        识别 UIWebview 的提交按钮点击

        时间:2023-07-06
      1. <legend id='DHgBS'><style id='DHgBS'><dir id='DHgBS'><q id='DHgBS'></q></dir></style></legend>

        <small id='DHgBS'></small><noframes id='DHgBS'>

          <tfoot id='DHgBS'></tfoot>

                  <tbody id='DHgBS'></tbody>
                • <bdo id='DHgBS'></bdo><ul id='DHgBS'></ul>
                  <i id='DHgBS'><tr id='DHgBS'><dt id='DHgBS'><q id='DHgBS'><span id='DHgBS'><b id='DHgBS'><form id='DHgBS'><ins id='DHgBS'></ins><ul id='DHgBS'></ul><sub id='DHgBS'></sub></form><legend id='DHgBS'></legend><bdo id='DHgBS'><pre id='DHgBS'><center id='DHgBS'></center></pre></bdo></b><th id='DHgBS'></th></span></q></dt></tr></i><div id='DHgBS'><tfoot id='DHgBS'></tfoot><dl id='DHgBS'><fieldset id='DHgBS'></fieldset></dl></div>
                • 本文介绍了识别 UIWebview 的提交按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个带有多个按钮的 UIWebView 页面.需要识别UIWebView的哪个按钮被点击.

                  I have a UIWebView page with multiple button . Need to identify which button is clicked of the UIWebView.

                  UIWebview 加载内容的页面源:

                  Page source for UIWebview load contents:

                          <form action="settings_personal.php" data-ajax="false" method="post">   
                              <input type="submit" name ="btn_settings_personal" value=" Goals (Personal data) " data-icon="star" data-theme="g" />
                          </form> 
                  
                          <form action="settings_global.php" data-ajax="false" method="post"> 
                              <input type="submit" name ="btn_settings_global" value=" Settings " data-icon="gear" data-theme="g" />
                          </form>
                          <form action="" data-ajax="false" method="post">    
                              <input type="submit" name ="btn_web_access" value=" Web Plattform Access " data-icon="plus" data-theme="h" />
                          </form>     
                  

                  我需要识别为btn_web_access"命名按钮单击的按钮???

                  I need to identify button clicked for 'btn_web_access' named button ???

                  我已经实现了以下:

                  - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{
                  
                   NSString* clicked = [self.webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('btn_web_access').click();"];
                  
                      NSLog(@"CLICK %@",clicked);
                  
                  }
                  

                  但它没有用..提前谢谢.

                  but its of no use..Thanks in advance.

                  推荐答案

                  只要使用请求的URL属性来区分加载请求的目标即可:

                  Just use the request's URL attribute to distinguish the load request's target:

                  - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{
                  
                      NSLog(@"url: %@", [[request URL] absoluteString]);
                  
                      return YES;
                  
                  }
                  

                  根据调用的 URL,您可以知道您当前显示的网页的哪个按钮(甚至是任何链接)被点击了.然后执行所需的操作,不要忘记返回一个 BOOL 值,指示是否实际加载请求的 URL.

                  Based on the URL being called, you know which button (or even any link) of your currently shown webpage was clicked. Then take the action being needed and don't forget to return a BOOL value indicating wether or not to actually load the requested URL.

                  在 Swift 中你可能有

                  In Swift you might have

                  func webView(webView:UIWebView,
                            shouldStartLoadWithRequest request:NSURLRequest,
                            navigationType:UIWebViewNavigationType) -> Bool
                      {
                      if (navigationType == .FormSubmitted)
                          {
                          print("was the 'submit' form")
                          }
                  
                      let u = request.mainDocumentURL
                      print("local or remote url was " ,u)
                  
                      return true // allow the form to in fact send the form
                      }
                  

                  这篇关于识别 UIWebview 的提交按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:我的按钮在 iPhone 6 和 6 plus 上居中,但在 iPhone 5 上不居中 下一篇:buttonWithType' 不可用:使用对象构造 'UIButton(type:)

                  相关文章

                • <legend id='C4ivW'><style id='C4ivW'><dir id='C4ivW'><q id='C4ivW'></q></dir></style></legend>

                  <small id='C4ivW'></small><noframes id='C4ivW'>

                  <tfoot id='C4ivW'></tfoot>
                    <i id='C4ivW'><tr id='C4ivW'><dt id='C4ivW'><q id='C4ivW'><span id='C4ivW'><b id='C4ivW'><form id='C4ivW'><ins id='C4ivW'></ins><ul id='C4ivW'></ul><sub id='C4ivW'></sub></form><legend id='C4ivW'></legend><bdo id='C4ivW'><pre id='C4ivW'><center id='C4ivW'></center></pre></bdo></b><th id='C4ivW'></th></span></q></dt></tr></i><div id='C4ivW'><tfoot id='C4ivW'></tfoot><dl id='C4ivW'><fieldset id='C4ivW'></fieldset></dl></div>

                        <bdo id='C4ivW'></bdo><ul id='C4ivW'></ul>