Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly your issue, i.e., how to make to <code>UIWebView</code> send messages one another, I would that by creating an intermediate controller.</p> <p>Your controller would act as a <code>UIWebViewDelegate</code> for both <code>UIWebView</code>s and its responsibilities would be:</p> <ol> <li><p>creating the second <code>UIWebView</code> (hosting the popup window) by intercepting <code>-webView:shouldStartLoadWithRequest:navigationType:</code> (what I think you are already doing);</p></li> <li><p>intercept the click on your popup window and then using <code>– stringByEvaluatingJavaScriptFromString:</code> to retrieve whatever information it needs;</p></li> <li><p>pass that information to the first <code>UIWebView</code> by means of <code>– stringByEvaluatingJavaScriptFromString:</code>.</p></li> </ol> <p>I have no information as to what kind of data is passed back from the second page to the first one, so I cannot be more detailed.</p> <p>Anyway, I think that using a second <code>UIWebView</code> for the popup window will simply breaks the DOM parent/child relationship (because you have two of them), so you have to resort to some more manual processing or modify the design of your web app.</p> <p>EDIT:</p> <p>After reading your comment:</p> <ol> <li><p>UIWebView is really greedy as to touches. If intercepting clicks on links through <code>-webView:shouldStartLoadWithRequest:navigationType:</code> is not enough, you can resort to overriding <code>-(void)sendEvent:(UIEvent*)event</code> in your own <code>UIWindow</code> derived class; but this is necessary only if you mix a UIWebView and a, e.g., UIScrollView or when you want to handle multi-touches; look <a href="https://stackoverflow.com/questions/1532778/how-to-respond-to-touch-events-in-uiwindow">here</a> for more info;</p></li> <li><p>here an example of how you can execute javascript:</p> <p><code>NSString *jsCall = [NSString stringWithFormat:@"yourFunction(%@);", arg];</code> <code>[webView stringByEvaluatingJavaScriptFromString:jsCall];</code></p></li> </ol> <p>You can use this in several different ways:</p> <pre><code> `jsCall1 = @"var func = function(id) { var obj = document.getElementById(id); return id.value; }; func('dataObject');"; `jsDataString = [popUp stringByEvaluatingJavaScriptFromString:jsCall1]; `jsCall2 = NSString stringWithFormat:@"storeDataFromPopup(%@);", jsDataString];` `[parentUIWebView stringByEvaluatingJavaScriptFromString:jsCall1];` </code></pre> <p>EDIT 2:</p> <p>A test suggestion: put the following code in your delegate class:</p> <pre><code> - (void)webViewDidFinishLoad:(UIWebView*)webView { .... NSString* aaa = [_label stringByEvaluatingJavaScriptFromString:@"f();"]; NSLog(@"AAA: %@", aaa); } </code></pre> <p>The HTML contains the following snippet:</p> <pre><code> &lt;script type='text/javascript'&gt;function f() { alert('called!');} alert('javascript OK!');&lt;/script&gt;" </code></pre> <p>it will give you a first alert meaning that js parsing was ok, and a second meaning that the f function was called from webViewDidFinish. I did a simple text getting a web page and adding the javascript snippet to it, and it worked.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload