I am passing my data from javascript to objective-c. for that I am using IFRAME.
Here is my code:
context.html
function openCustomURLinIFrame(src)
{
alert(src);
var rootElm = document.documentElement;
var newFrameElm = document.createElement("IFRAME");
newFrameElm.setAttribute("src",src);
document.documentElement.appendChild(newFrameElm);
//remove the frame now
newFrameElm.parentNode.removeChild(newFrameElm);
newFrameElm = null;
}
Indoor.m
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSLog(@"Loading: %@", [request URL]);
NSURL *url = [request URL];
NSString *urlStr = url.absoluteString;
return [self processURL:urlStr];
}
I am getting
Loading: about:blank
I am using xCode 8.2.1 it is working well in IOS 9.3 but not working in iOS 10.2.
Edit:
My alert screenshot in .html file.
Edit:
Method in html file in which I call openCustomURLinIFrame
method.
function calliOSFunction(functionName, args, successCallback, errorCallback)
{
var url = "js2ios://";
var callInfo = {};
callInfo.functionname = functionName;
//alert("Custom menu clicked !!"+functionName);
if (successCallback)
{
//alert("Success !!"+functionName);
callInfo.success = successCallback;
}
if (errorCallback)
{
//alert("Error !!"+functionName);
callInfo.error = errorCallback;
}
if (args)
{
//alert("args !!"+args);
callInfo.args = args;
}
url += JSON.stringify(callInfo)
openCustomURLinIFrame(url);
}
Help me to resolve this issue.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…