Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Looks like you have an answer including the Objective-C code you need, but I would imagine that for the javascript you can simply fire the contents of the link's onclick or navigate to the appropriate url instead of going through the trouble of simulating a mouse click. Granted, I have not tested this in an iOS app but feel free to give it a shot: </p> <pre><code>var links = document.getElementsByTagName('a'); for(i=0;i&lt;links.length;i++) { if (links[i].innerHTML.indexOf('Test') != -1) { clickLink(links[i]); break; } } function clickLink(linkobj) { var onclickHandler = linkobj.getAttribute('onclick'); if (onclickHandler == null) window.location = linkobj.getAttribute('href').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); else eval(onclickHandler(linkobj)); } </code></pre> <p>By the way, there is an eval in this code that will run the contents of the onclick handler. This can be unsafe. If you only need to navigate to a location specified by the link then you may want to remove the portion dealing with onclick.</p> <p>A much simpler version of this is printed below (since your sample code does not appear to need to deal with onclick) which may be easier to use. In this case I am calling it after a 1-second delay, but in reality, since it seems that this code runs in response to a trigger on the iOS side (button click?), you should not use a delay and instead simply wait enable the trigger until loading is complete - <code>webViewDidFinishLoad</code>.</p> <pre><code>function clickLink() { var links = document.getElementsByTagName('a'); for (i = 0; i &lt; links.length; i++) { if (links[i].innerHTML.indexOf('Prev') != -1) { window.location = links[i].getAttribute('href').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); break; } } } setTimeout(clickLink, 1000); </code></pre> <p>jsFiddle which demonstrates this using your sample code: <a href="http://jsfiddle.net/fzKL7/5/" rel="nofollow">http://jsfiddle.net/fzKL7/5/</a></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.
    3. 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