I have a code where I need to access DOM object model in my Objective-C code. I am trying to execute a function that is suppose to return the content
NSString *functionScr = [NSString stringWithFormat: @"var fPreset=\"%@\";"
"var addFavorite = function() {"
" if (fPreset != '') {"
" var ft = window.document.createElement('div');"
" ft.innerHTML = decodeURIComponent(fPreset);"
" var f = ft.innerHTML;"
" var bub = encodeURIComponent(f.childNodes[1]);"
" return bub;"
" }"
" }",encodedHTML];
[context evaluateScript:functionScr];
JSValue *retVAL = [context evaluateScript:@"addFavorite();"];
when this executes I get an error
ReferenceError: Can't find variable: window
How can I access window object in JavascriptCore?
It's is not possible :( The DOM and any other window property is not available in the JavascriptCore. It is a pure JS engine