Take the 2-minute tour ×

I have successfully implemented UIWebView Search text, Now i want to navigate through all the next occurrence and previous, Can any one suggest something in UIWebView. help greatly appreciated.

Thanks a lot

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I was able to achieve the result using this javascript function

function goNext(){
function goPrev(){

function jump(nextOrPrev){

    prevSelected = currSelected;
    currSelected = currSelected + nextOrPrev;

    if (currSelected < 0){
        currSelected = uiWebview_SearchResultCount + currSelected;
    if (currSelected >= uiWebview_SearchResultCount){
        currSelected = currSelected - uiWebview_SearchResultCount;

    prevEl = document.getElementsByClassName("uiWebviewHighlight")[prevSelected];
    if (prevEl){
    el = document.getElementsByClassName("uiWebviewHighlight")[currSelected];

Do initialise currSelected=-1 in the beginning of your search function before element comparison, which should be something like this

if (element) {
        if (element.nodeType == 3) { //your code} }
share|improve this answer

Your Answer


