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

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

          <bdo id='RqNPW'></bdo><ul id='RqNPW'></ul>
      1. <tfoot id='RqNPW'></tfoot>
      2. 如何获取在 UIWebView 中显示的 HTML 页面的标题?

        时间:2023-10-22
          • <bdo id='Ok2uO'></bdo><ul id='Ok2uO'></ul>
          • <tfoot id='Ok2uO'></tfoot>

            1. <legend id='Ok2uO'><style id='Ok2uO'><dir id='Ok2uO'><q id='Ok2uO'></q></dir></style></legend>

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

                <tbody id='Ok2uO'></tbody>

                1. <i id='Ok2uO'><tr id='Ok2uO'><dt id='Ok2uO'><q id='Ok2uO'><span id='Ok2uO'><b id='Ok2uO'><form id='Ok2uO'><ins id='Ok2uO'></ins><ul id='Ok2uO'></ul><sub id='Ok2uO'></sub></form><legend id='Ok2uO'></legend><bdo id='Ok2uO'><pre id='Ok2uO'><center id='Ok2uO'></center></pre></bdo></b><th id='Ok2uO'></th></span></q></dt></tr></i><div id='Ok2uO'><tfoot id='Ok2uO'></tfoot><dl id='Ok2uO'><fieldset id='Ok2uO'></fieldset></dl></div>
                  本文介绍了如何获取在 UIWebView 中显示的 HTML 页面的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要从 UIWebView 中显示的 HTML 页面中提取标题标签的内容.这样做最可靠的方法是什么?

                  I need to extract the contents of the title tag from an HTML page displayed in a UIWebView. What is the most robust means of doing so?

                  我知道我能做到:

                  - (void)webViewDidFinishLoad:(UIWebView *)webView{
                      NSString *theTitle=[webView stringByEvaluatingJavaScriptFromString:@"document.title"];
                  }
                  

                  但是,这仅在启用 javascript 时有效.

                  However, that only works if javascript is enabled.

                  或者,我可以只扫描标题的 HTML 代码文本,但这感觉有点麻烦,如果页面的作者对他们的代码感到奇怪,可能会变得脆弱.如果涉及到这一点,在 iPhone API 中处理 html 文本的最佳方法是什么?

                  Alternatively, I could just scan the text of the HTML code for the title but that feels a bit cumbersome and might prove fragile if the page's authors got freaky with their code. If it comes to that, what's the best method to use for processing the html text within the iPhone API?

                  我觉得我忘记了一些明显的事情.有比这两种选择更好的方法吗?

                  I feel that I've forgotten something obvious. Is there a better method than these two choices?

                  根据这个问题的答案:UIWebView: Can You Disable Javascript?似乎没有办法在 UIWebView 中关闭 Javascript.因此,上面的 Javascript 方法将始终有效.

                  Following from the answer to this question: UIWebView: Can You Disable Javascript? there appears to be no way to turn off Javascript in UIWebView. Therefore the Javascript method above will always work.

                  推荐答案

                  对于那些只是向下滚动寻找答案的人:

                  For those who just scroll down to find the answer:

                  - (void)webViewDidFinishLoad:(UIWebView *)webView{
                      NSString *theTitle=[webView stringByEvaluatingJavaScriptFromString:@"document.title"];
                  }
                  

                  这将始终有效,因为无法在 UIWebView 中关闭 Javascript.

                  This will always work as there is no way to turn off Javascript in UIWebView.

                  这篇关于如何获取在 UIWebView 中显示的 HTML 页面的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 下一篇:UIWebView背景设置为Clear Color,但不透明

                  相关文章

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

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

                  1. <legend id='GBIyq'><style id='GBIyq'><dir id='GBIyq'><q id='GBIyq'></q></dir></style></legend>

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