javascript - How to determinate stringByEvaluatingJavaScriptFromString evaluation porcess complete? -
i'm reading html file uiwebview. in webviewdidfinishload i'm doing javascript function horizontal scroll. below code works fine. cant predict when javascript function finish.
in visible webview first load html file script run. can determinate javascript finishing in webviewdidfinishload.
- (void)webviewdidfinishload:(uiwebview *)webview { nsstring *scriptstring =@"javascript:function initialize() { var eelam = document.getelementsbytagname('body')[0]; var ourh = window.innerheight;var ourw = window.innerwidth; var fullh = eelam.offsetheight; var pagecount = math.ceil(fullh/ourh)+1; var padval = parseint((screen.width*10)/100);var currentpage = 0; var neww = pagecount*ourw;eelam.style.height = (ourh - 30)+'px';eelam.style.width = (neww)+'px';eelam.style.webkitcolumngap = '5px'; eelam.style.margin = '25px'; eelam.style['margin-left']='2px';eelam.style.webkitcolumncount = pagecount; window.interface.setpagecount(pagecount);window.interface.setcolumnwidth(screen.width);window.interface.setcontent(eelam);window.interface.setcolumngap(padval);};"; // set font nsstring *jsstring = [[nsstring alloc] initwithformat:@"document.getelementsbytagname('body')[0].style.webkittextsizeadjust= '%d%%'", textfontsize]; [mywebview stringbyevaluatingjavascriptfromstring:scriptstring]; [mywebview stringbyevaluatingjavascriptfromstring:@"javascript:initialize()"]; [mywebview stringbyevaluatingjavascriptfromstring:jsstring]; // scroll disable uiview* row = nil; for(row in webview.subviews){ if([row iskindofclass:[uiscrollview class] ]){ uiscrollview* scrollrow = (uiscrollview*) row; scrollrow.scrollenabled = no; scrollrow.bounces = no; scrollrow.pagingenabled=yes; } } // code not use handle issue if ([[mywebview stringbyevaluatingjavascriptfromstring:@"document.readystate"] isequaltostring:@"complete"]) { } } please advise me,
thanks in advance,
the function not asynchronous. finishes right before returning value evaluation function.
Comments
Post a Comment