when clicked on link that is supposed to open another window it UIWebView, it simply does nothing. how can i detect this so that i can simply load the requested page in the same window? is it possible at all? thanks
I can't speak to your specific problem but if you've setup your webview to have a delegate then use this event and code to trap what a user has clicked on.. and a few more actions as well
__________________
---------------------------------------------------------------------- I love being a dad, flying airplanes and writing code.
----------------------------------------------------------------------
Follow me on Twitter: @BostonMerlin
Feed your brain on Twitter: @iPhoneDev101
----------------------------------------------------------------------
iPhone Apps:
wow that code sample looks like one of my pastebins. Change the scheme to javascript instead of http. scheme is everything before the colon and javascript commands are run with javascript:window.whatever.etc.youget.the.idea
Hello;
I'm stuck on the same problem and am trying to get my code to work. I added these two lines of code to this delegate method, but no luck.
Forgive me, but what should I replace "inurl, blah, blah2" with? I don't understand.
Thanks!
I am loading an External web page in the UIWebView. When the web page loads, there is an Alert Box ( with OK and Cancel buttons) with some Suggestion/ Info about the web page. I want to block this Alert Box when the web page loads in the UIWebView component in my iphone app. How can I implement in my code?
(void)webViewDidFinishLoad:(UIWebView *)webView
{
[webView stringByEvaluatingJavaScriptFromString:@"{\
var a = document.getElementsByTagName(\"a\"); \
for (var i=0; i<a.length; i++) \
a[i].target = \"_self\";\
}"];
}
It's a UIWebViewDelegate method implementation. Maybe not a best place, but...
It seems that there's no way to change the reference's targets, except for applying javascript.
Hope that it will help someone.
Be careful with this code. It works well on most sites but this will make Gmail and probably other javascript complex websites stop working. I'm working on / looking for a safer solution. Will let you know if and when I find it.