title: UIWebView not calling my Javascript function
body: <p>I am aware that this question is already posted lot many times. But none of them are helping me to solve my issue. Please consider reading entire question before downvote :-)</p>
  
  <p>So, for I have below lines of code</p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
      NSURL * url = [NSURL URLWithString: @"https://www.w3schools.com/code/tryit.asp?filename=FEGU9IV4SAK8"];
  
      NSURLRequest * request = [NSURLRequest requestWithURL:url];
  
      self.webView.delegate = self;
      [self.webView loadRequest:request];
  }
  
  #pragma mark - UIWebView Delegates
  
  - (void) webViewDidFinishLoad:(UIWebView *)webView {
  
      NSString * jsString = [NSString stringWithFormat:@"test()"];
      [webView stringByEvaluatingJavaScriptFromString:jsString] ;
  
  
  //This code is working. Able to prompt "Hello"    
  //     jsString = [NSString stringWithFormat:@"alert('Hello');"];
  //    [webView stringByEvaluatingJavaScriptFromString:jsString] ;
  }
  
  - (BOOL)webView:(UIWebView *)webView
  shouldStartLoadWithRequest:(NSURLRequest *)request
   navigationType:(UIWebViewNavigationType)navigationType;
  {
  
     // ignore legit webview requests so they load normally
      if (![request.URL.scheme isEqualToString:kSchemeName]) {
          return YES;
      }
  
  
      // look at the actionType and do whatever you want here
      if ([actionType isEqualToString:kJSActionForPay]) {
  
          //Call objective-c method - Success 
      }
  
      // make sure to return NO so that your webview doesn't try to load your made-up URL
      return NO;
  }
  </code></pre>
  
  <p>So, Far I have tried / understood. </p>
  
  <p>[1] Call JS function only after web view loaded. (used delegate)</p>
  
  <p>[2] Able to prompt "Hello" from</p>
  
  <p><code>[webView stringByEvaluatingJavaScriptFromString:@"alert('Hello')"] ;</code></p>
  
  <p>[3] Changes done in HTML side</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Page Title&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1 id="id1"&gt;My Heading 1&lt;/h1&gt;
  &lt;button type="button" 
  onclick="document.getElementById('id1').style.color = 'red'"&gt;
  Click Me!&lt;/button&gt;
  &lt;/body&gt;
       &lt;script&gt; 
        function test() {
          alert("Started");
       }
       &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Please help to find out what I am missing in HTML Side ?  or In my native Objc?</strong></p>
  
  <p><strong>EDIT 1</strong>: 
  As @Andy suggested, I loaded html from local. Then I am able to call JS function "test()" </p>