xcode - WebView not run JS -
i trying run js script on webview. script return's 2 script (1 lib + 1 image creator). when run on browser runs perfect. when run on mobile (webview) cant see anything.
nsstring * script = [nsstring stringwithformat:@"<body><body><script data-server=\"adman|http://adman.gr/\">(function() {document.write('<sc'+'ript data-ws=\"1015\" data-h=\"sport-fm.adman.gr\" data-s=\"320x50\" data-iframe=\"false\" data-kw=\"\" data-p=\"\" src=\"http://static.adman.gr/adman.js\"></sc'+'ript>');}());</script></body></body>"]; [_webview loadhtmlstring:script baseurl:nil]; [ _webview stringbyevaluatingjavascriptfromstring: @"function()" ];
ah, met issue before.
here solution:
put script js file. load script,
static nsstring *jshandler; jshandler = [nsstring stringwithcontentsofurl:[[nsbundle mainbundle] urlforresource:@"script" withextension:@"js"] encoding:nsutf8stringencoding error:nil]; [self.webview stringbyevaluatingjavascriptfromstring:jshandler];
done!
Comments
Post a Comment