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

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

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

      1. 使用 UIWebView 调用 Javascript

        Calling Javascript using UIWebView(使用 UIWebView 调用 Javascript)

              1. <small id='gvBir'></small><noframes id='gvBir'>

                  <tbody id='gvBir'></tbody>
              2. <legend id='gvBir'><style id='gvBir'><dir id='gvBir'><q id='gvBir'></q></dir></style></legend>

                  <bdo id='gvBir'></bdo><ul id='gvBir'></ul>
                  <tfoot id='gvBir'></tfoot>

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

                  问题描述

                  我正在尝试使用该函数在 html 页面中调用 javascript -

                  I am trying to call a javascript in a html page using the function -

                  View did load function
                  {
                  
                      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                      NSString *documentsDirectory = [paths objectAtIndex:0];
                      NSString *writablePath = [documentsDirectory stringByAppendingPathComponent:@"BasicGraph.html"];
                      NSURL *urlStr = [NSURL fileURLWithPath:writablePath];
                  
                      NSFileManager *fileManager = [NSFileManager defaultManager];
                      NSString *myPathInfo = [[NSBundle mainBundle] pathForResource:@"BasicGraph" ofType:@"html"];
                      [fileManager copyItemAtPath:myPathInfo toPath:writablePath error:NULL];
                  
                      [graphView loadRequest:[NSURLRequest requestWithURL:urlStr]];
                  }
                  
                  - (void) webViewDidFinishLoad:(UIWebView *)webView
                  {
                      [graphView stringByEvaluatingJavaScriptFromString:@"methodName()"];
                  }
                  

                  这是 html 页面上的 javascript -

                  Here is the javascript on the html page -

                  <script>
                      function methodName()
                        {
                           // code to draw graph
                        }
                  

                  但是,函数 methodName() 没有被调用,但是在 window.onload = function () 之后一切正常..

                  However, the function methodName() is not getting called but after window.onload = function () everything is working fine..

                  我正在尝试将 RGraphs 集成到我的应用程序中,而 Basic.html 是其中的 html 页面javascript是写的.

                  I am trying to integrate RGraphs into my application and Basic.html is the html page in which the javascripts are written.

                  如果有人能帮我解决这个问题,那就太好了.

                  It would be great if someone could help me out with this.

                  推荐答案

                  简单:你尝试在页面加载之前从 Objective-C 执行 JS 函数.

                  Simple: You try to execute the JS function from Objective-C before the page even has been loaded.

                  实现 UIWebView 的委托方法 webViewDidFinishLoad: 在您的 UIViewController 中并在其中调用 [graphView stringByEvaluatingJavaScriptFromString:@"methodName()"]; 以确保在页面之后调用该函数已加载.

                  Implement the UIWebView's delegate method webViewDidFinishLoad: in your UIViewController and in there you call [graphView stringByEvaluatingJavaScriptFromString:@"methodName()"]; to make sure the function gets called after the page has been loaded.

                  这篇关于使用 UIWebView 调用 Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                  How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)
                  <legend id='d6I85'><style id='d6I85'><dir id='d6I85'><q id='d6I85'></q></dir></style></legend>

                  <tfoot id='d6I85'></tfoot>

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