How To Call A JavaScript Function Which Returns An HTML String In Body Using Swift WebView?
I have an HTML file which is generated after calling a JavaScript fucntion in the body. I need to remove the JavaScript call from the HTML and call it from my Swift using webView
Solution 1:
You would just need to change:
let htmlReturned = webView.stringByEvaluatingJavaScriptFromString(jsString)!
here jsString would equal the name of your javascript function. However the problem with this and webView is that you can't pass along object values from your iOS code into the javascript function(at least that I know of, please prove me wrong if we can:) )....So you would need to change the function signature to accept strings and numbers
function cbc(wbc, wbcCol, hgb, hbcCol, hct, hctCol, plt, pltCol){}
would end up with:
let htmlReturn = webview.stringByEvaluatingJavascriptFromString("cbc(14, \"red\", 12, \"orange\", 12, \"blue\", 12.4, \"green\")")
Post a Comment for "How To Call A JavaScript Function Which Returns An HTML String In Body Using Swift WebView?"