D Danneman101 macrumors 6502 Original poster Aug 14, 2008 361 1 Feb 23, 2009 #1 How can I access an objc variable (say an integer) from the javascript-code of a html-page within a uiwebview? Is it even possible?
How can I access an objc variable (say an integer) from the javascript-code of a html-page within a uiwebview? Is it even possible?
J jnic macrumors 6502a Oct 24, 2008 567 0 Cambridge Feb 23, 2009 #2 I've had limited success doing something similar by modifying the DOM using stringByEvaluatingJavaScriptFromString:, but it's basically trial and error.
I've had limited success doing something similar by modifying the DOM using stringByEvaluatingJavaScriptFromString:, but it's basically trial and error.
D Danneman101 macrumors 6502 Original poster Aug 14, 2008 361 1 Feb 23, 2009 #3 There is very little documentation on it, and no examples to mimic/alter. Was your solution to call the javascript and pass along the variabel as a parameter? Pseudocode: Code: - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)myJSFunction(returnParameter)
There is very little documentation on it, and no examples to mimic/alter. Was your solution to call the javascript and pass along the variabel as a parameter? Pseudocode: Code: - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)myJSFunction(returnParameter)
J jnic macrumors 6502a Oct 24, 2008 567 0 Cambridge Feb 23, 2009 #4 Danneman101 said: Was your solution to call the javascript and pass along the variabel as a parameter? Click to expand... Yup. Code: [webview stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"document.write(\"%d\");", var]]; etc.
Danneman101 said: Was your solution to call the javascript and pass along the variabel as a parameter? Click to expand... Yup. Code: [webview stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"document.write(\"%d\");", var]]; etc.
D Danneman101 macrumors 6502 Original poster Aug 14, 2008 361 1 Feb 23, 2009 #5 Alright, Im getting somewhere - thanks for your help Finally, just let me get this straight: in the code you substitute the %d with var?
Alright, Im getting somewhere - thanks for your help Finally, just let me get this straight: in the code you substitute the %d with var?
J jnic macrumors 6502a Oct 24, 2008 567 0 Cambridge Feb 23, 2009 #6 That's right. In this case, "var" is an integer. See stringWithFormat and String Format Specifiers for more.
That's right. In this case, "var" is an integer. See stringWithFormat and String Format Specifiers for more.
D Danneman101 macrumors 6502 Original poster Aug 14, 2008 361 1 Feb 23, 2009 #7 Great - thanks again for the help Much appreciated!