Reputation:
What is the lifetime of Javascript code used with stringByEvaluatingJavaScriptFromString:
?
I found some code repeatedly using stringByEvaluatingJavaScriptFromString:
with same script and with no page reloads in between. Is that good to do ?
Is the stringByEvaluatingJavaScriptFromString:
injects the entire script in to active page in UIWebView
and make it available till reload or navigate to another page ?
Is there any apple documentation regarding the same ?
Upvotes: 0
Views: 190
Reputation:
The javascript code injected will be available throughout the life of the current page loaded in the UIWebView
. That is, if called stringByEvaluatingJavaScriptFromString:
with some script, that will be available till a new page is loaded in the UIWebView
or the page is refreshed. No need to inject the entire script every time to evaluate something using the same.
Checked it with injecting some functions first and called the functions (only) later.
Upvotes: 0