iphone - ios - How to declare the javascript in ios? -


i'm invoking javascript in below code,it's working perfectly,then append javascript html content,when i'm checking url scheme in if condition fails.

- (void)connectiondidfinishloading:(nsurlconnection *)connection  {      if(_data)      {         nsstring* content = [[nsstring alloc] initwithdata:_data                                                   encoding:nsutf8stringencoding];          [_data release];         _data = nil;          nsstring *jsstring = @"<script type='text/javascript'>\         window.external =\         {\         'notify': function(s) { document.location = 'acs://settoken?token=' + s; },\         'notify': function(s) { document.location = 'acs://settoken?token=' + s; }\         }\         </script>";          content = [jsstring stringbyappendingstring:content];         [webview loadhtmlstring:content baseurl:_url];     } }    - (bool)webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request  navigationtype:(uiwebviewnavigationtype)navigationtype  {      if(_url)      {          if([_url isequal:[request url]])         {             return yes;         }          [_url release];     }     _url = [[request url] retain];     nsstring* scheme = [_url scheme];     //here i'm checking condition      if([scheme isequaltostring:@"acs"])     {         // parse json url parameter dictionary         nsdictionary* pairs = [self parsepairs:[_url absolutestring]];         if(pairs)         {             wacloudaccesstoken* accesstoken;             accesstoken = [[wacloudaccesstoken alloc] initwithdictionary:pairs];             [wacloudaccesscontrolclient settoken:accesstoken];              [self dismissmodalviewcontrolleranimated:yes];         }          return no;     }      [nsurlconnection connectionwithrequest:request delegate:self];      return no;  } 

any ideas? in advance.

check 1 ,

[webview stringbyevaluatingjavascriptfromstring:@"window.external =\ {\ 'notify': function(s) { document.location = 'acs://settoken?token=' + s; },\ 'notify': function(s) { document.location = 'acs://settoken?token=' + s; }\ }"]; 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -