how to naviagate html url to other window - iphone

Special thanks in advance for sending me answer........
I m the beginner in iphone development. I was calling html page in the UISegment Controller.The url in that page html page is open in the same page. In html page i wrote the following code
www.google.com
But it open that url in UISegment Control of WebView on same page. I want that url open in new page of safari browser in iphone.

You can assign a delegate to your web view.
In the delegate's class, implement -webView:shouldStartLoadWithRequest:navigationType:. Then use UIApplication's -openURL: to close the app and open the page in MobileSafari.

google in a new window

Related

iPhone SDK - Add a "Add to Home Screen" button in a UIWebView

I have a native iPhone app, which has a UIWebView component to it. I am trying to see if I can replicate the "Add to Home Screen" button that is present in the tab bar options in Safari.
Is this possible inside a UIWebView within a native app?
Thanks!
Brett
[I presume your question is about replicating the action associated with add to home screen, rather than replicating the appearance of the button itself (which being pedantic is what you actually wrote).]
As others have said this isn't possible.
What you could do is programatically launch Safari from within your app and give it the URL of a page to load which is your page.
When your page is loaded it has some sort of animation and shows the user where the add to home screen button is and tell them to press it after clicking a link which is displayed in your web page. When the users click on the link it takes them to whatever page it is that you would like saved to the desktop, and you hope they follow your instructions.
If you register your app to handle a proprietary url scheme the users can get back to your app from within Safari by clicking on a link using your app's url scheme.
The web pages that you seed Safari with must however be remote pages, you cannot give Safari a page in your app's bundle or that your app has downloaded as Safari cannot read pages from your app's sandbox.
The short answer is no, you can't. Apple does not let you.
Here's a similar question which may help you come up with other possibilities:
Javascript for "Add to Home Screen" on iPhone?
If I had to think of a work around off the top of my head, you could create an javascript pop-up which instructs them how to. It could say something like tap this button to go to mobile safari then tap action -> add to home screen.
Execute the Javascript with UIWebView's method:
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
Hope this helps.
You can use UIActivityViewController with your url as the activity items
NSArray *activityItems = #[title, url];
And then you can exclude the activities that you don't want. I think it´s the only way for now.

How to place a web browser inside an iphone application?

such that when the user open the application the website referenced will be loaded in the web browser
I know the code the will open a URL with in an application
[NSURL URLWithString:#"http://www.apple.com"]];
But this is not what I need I need the application to display the web browser within its form.
If you are only to show one page I suggest you should use ModalViewController to present the page inside your app and put a UIWebView in it.
If you are to render the web page as an application than you should use UIWebView
If you want to present some pages but also want to make use of navigation functions of the safari inside your app you can use DLWebView framework which suppors ModalView with navigation function.
Here you can watch the video how it works: http://dlinsin.github.com/2011/04/24/DLWebView.html
You need UIWebView class : UIWebView Class Reference
Also you can try to search for a ready webview with all needful buttons.
Have you looked into UIWebView?
If you need browser functionality within your own app, you will need to create your own, i.e. it's not possible to embed the Safari browser within a view in your own app.

No response after submitting form on iPad from UIWebView

I am currently opening a webpage in UIWebView and submitting a form which performs a query on the server side and youtube video is returned (if available). I have no say/control over the server side implementation.
This webview works fine on iPhone/iPod, however, when I try to run the same app on iPad there is no response after submitting the form.
I created a dummy app, compiled on iOS 3.2 and problem is still there.
I put NSLogs in webview delegate methods which shows that after the form is submitted (UIWebViewNavigationTypeFormSubmitted) nothing happens.
I'm unable to figure out why this happens only on iPad and not on iPhone/iPod Touch.
I have created the webview in IB and setting the URL is viewDidLoad
[viewTourWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.realestatetour.com/mobiletours.htm"]]];
The URL for reference is http://www.realestatetour.com/mobiletours.htm
Enter the Tour ID as 10.
Thanks
The reason it wasn't working is because the form opens the result in a new page, (i.e. _blank) and apparantly all links opening in new window are ignored by uiwebview and its delegates.
I found 2 possible solutions for this:
1) Modifying the html using javascript to replace all _blank with _self for all anchor tags.
(source)
2) A more elegant solution which works for handling links which open a new window.
(source)
In my case i recreated the web page displaying form on the iphone app and changed _blank to _self.

Disable the Alert Box in UIWebView

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?
Thanks for your reply. I am not in-charge for the external web page(but i could ask the concern web page owner to do the changes with respect to following requirement). The requirement is that the Alert Box (used to tell about my iphone app) could be shown when we view the web page in iPhone Safari browswer , but not in UIWebView in which I am using the same web page) of my iphone app. I am using the same web page url both in iPhone Safari and in my iPhone app with UIWebView. So requirement is show the Alert box when we view the web page in iPHone Safari and don't show the Alert box when we view the same web page in iPhone app (within in UIWebView). Hope I have clearly explained my requirement. Please give any solution for this.
using stringByEvaluatingJavaScriptFromString: method you can change anything you want on the page with any javascript you provide, so you can overload or replace the alert function to do what you want
Are you the one 'in charge' of this external web page? If that's the case, you could do something like this:
Make the UIWebView load externalpage.html?noalert instead of externalpage.html.
Then on externalpage.html you can check whether this query string variable exists, and only show the alert() if it doesn't:
if(!document.location.search || document.location.search.substring(1) != 'noalert') {
alert('Boo!');
}
duplicate: UIWebView: Can I disable the javascript alert() inside any web page?
Since a UIWebView translates all Javascript alerts into native UIAlertViews it is fairly simple to block it on the native end. Looking into UIAlertView.h there is only one public method for showing an alert which is conveniently called: - (void)show;.
#interface UIAlertView (Blocker)
#end
#import "UIAlertView+Blocker.h"
#implementation UIAlertView (Blocker)
- (void)show {
return;
}
#end
You can find the answer here: https://stackoverflow.com/a/21698251/2377378

Launch Safari from iPhone App

I know that i can use the following code to launch my own url, but i want the user to continue their workflow after using my bookmarklet so therefore don't want to open a new tab and have them re-load the url i put into the url variable?
NSURL url* = [NSURL URLWithString:#"http://google.com"];
[[UIApplication sharedApplication] openUrl:""];
Can this be done?
There is no way to open Safari without actually quitting your app and opening Safari. Or to somehow automatically return the user to your app from Safari once the URL you opened loads.
Or am I misunderstanding the question?
Actually, you can delegate a URL handler to your app. A smart example is shown here:
http://www.mobileorchard.com/lite-to-paid-iphone-application-data-migrations-with-custom-url-handlers/
The scenario is:
- register URL handler
- open Safari as normal
- get Safari to use your custom URL handler that should open your app (eg: myapp://)
Have a look at the way Flickr iPhone app does the authentication.
Can you use 'about:blank' as the url? That should just open Safari with a blank page. I assume this would be similar to tapping the 'number' button in the bottom right then selecting 'new page'.