Javascript not executing in iPhone -


i want execute javascript code iphone application using uiwebview.

but html part executing while javascript part not executing. it's not showing error.

nsmutablestring *htmlcode = [nsmutablestring stringwithstring:@"<!doctype html>"];   [htmlcode appendstring:@"<html><head><tilte> sadaf </title>"];  [htmlcode appendstring:@"<h1>my first web page</h1>"];   [ htmlcode appendstring:@" <p id='demo'>this paragraph.</p>"]; [self.webview loadhtmlstring:htmlcode baseurl:nil];   webview.delegate= self;  [webview stringbyevaluatingjavascriptfromstring:@"<script type='text/javascript'>document.getelementbyid('demo').innerhtml=date();</script>   "]; 

check if delegate has been set correctly.

- (void)viewdidload  {     [super viewdidload];      //  init , create uiwebview     webview = [[uiwebview alloc] initwithframe:cgrectmake(0, 88, 320, 400)];      webview.autoresizessubviews = yes;     webview.autoresizingmask=(uiviewautoresizingflexibleheight | uiviewautoresizingflexiblewidth);     [webview  setdelegate:self];//set web view delegates web view     nsmutablestring *htmlcode = [nsmutablestring stringwithstring:@"<!doctype html>"];      [htmlcode appendstring:@"<h1>my first web page</h1>"];      [htmlcode appendstring:@" <p id='demo'>this paragraph.</p>"];      [htmlcode appendstring:@"</form> </body> </html> "];      [self.webview loadhtmlstring:htmlcode baseurl:nil];      [self.view addsubview:webview];//add web view content view }  - (void) webviewdidfinishload:(uiwebview *)webview1 {     nslog(@"webviewdidfinishload");     [webview1 stringbyevaluatingjavascriptfromstring:@"alert('hi');document.getelementbyid('demo').innerhtml=date();"]; } 

this may help!


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -