Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8328517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:28:16+00:00 2026-06-09T01:28:16+00:00

I am currently using ChildBrowser in phoneapp to open a website. However, I would

  • 0

I am currently using ChildBrowser in phoneapp to open a website. However, I would like to open all external links of this website to open in Safari.

I do not have control over the source of this website.

My understanding is that I have to modify ChildBrowser to open all links starting with “http” in Safari.

I can’t exactly read Objective-C, but I believe the code below is relevant.

- (void)loadURL:(NSString*)url
{
    NSLog(@"Opening Url : %@",url);

    if( [url hasSuffix:@".png" ]  || 
        [url hasSuffix:@".jpg" ]  || 
        [url hasSuffix:@".jpeg" ] || 
        [url hasSuffix:@".bmp" ]  || 
        [url hasSuffix:@".gif" ]  )
    {
        [ imageURL release ];
        imageURL = [url copy];
        isImage = YES;
        NSString* htmlText = @"<html><body style='background-color:#333;margin:0px;padding:0px;'><img style='min-height:200px;margin:0px;padding:0px;width:100%;height:auto;' alt='' src='IMGSRC'/></body></html>";
        htmlText = [ htmlText stringByReplacingOccurrencesOfString:@"IMGSRC" withString:url ];

        [webView loadHTMLString:htmlText baseURL:[NSURL URLWithString:@""]];

    }
    else if ( [url hasPrefix:@"http" ])
    {
        //I have added in this else if.
    }
    else
    {
        imageURL = @"";
        isImage = NO;
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
        [webView loadRequest:request];
    }
    webView.hidden = NO;
}

Any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:28:17+00:00Added an answer on June 9, 2026 at 1:28 am

    The easiest way I’ve found to do this is, if you know the Domain Host name that you will initially be requesting with childBrowser and you don’t plan on requesting any other Domains then you can write this event right into the ChildBrowserViewController.m file.

    - (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request     navigationType:(UIWebViewNavigationType)navigationType
    {
        NSURL *url = [request URL];
        NSString* domain = [url host];
    
        // Intercept the external http requests and forward to Safari.app
        // Otherwise forward to the PhoneGap WebView
        if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"] || [[url scheme] isEqualToString:@"www"]) {
            if ( [domain isEqualToString:@"YOURDOMAIN.NAME] ) {
                return YES;
            } else {
                [[UIApplication sharedApplication] openURL:url];
                return NO;
             }
        } else {
             return YES;// [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
        }
    }
    

    This will catch all requests made by childBrowser and if they match standard URL convention (preceding with HTTP, HTTPS, or WWW) and they are not your Domain Host name that you preset then it will foce them to open in Safari. Then when the user returns to your app they will still be on the previous page they where when they clicked the link.

    I messed with this for hours until I came up with this.

    If you need to be able to open more than one Domain Host with childBrowser but still want each one to open all external links leading away from that current domain in Safari I would suggest the following.

    Add the following to ChildBrowserViewController.h

    BOOL scaleEnabled;
    BOOL isImage;
    NSString* originalURL; <- THIS RIGHT HERE
    NSString* imageURL;
    

    And this

    @property(retain) NSString* imageURL;
    @property(retain) NSString* originalURL; <- THIS RIGHT HERE
    @property(assign) BOOL isImage;
    

    Then add the following to ChildBrowserViewController.m

    @synthesize imageURL;
    @originalURL; <- THIS RIGHT HERE
    @synthesize supportedOrientations;
    @synthesize isImage;
    

    And add the following

    - (void)loadURL:(NSString*)url
    {
        originalURL = url; <- THIS RIGHT HERE
        NSLog(@"Opening Url : %@",url);
    

    And then in the method I posted above change the following

        NSURL *url = [request URL];
        NSString* domain = [url host];
    
        NSURL *oURL = [NSURL URLWithString: originalURL]; <- THIS RIGHT HERE
        NSString* oDomain = [oURL host]; <- THIS RIGHT HERE
    
        // Intercept the external http requests and forward to Safari.app
        // Otherwise forward to the PhoneGap WebView
        if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"] || [[url scheme] isEqualToString:@"www"]) {
            if ( [domain isEqualToString:oDomain] ) { <- THIS RIGHT HERE
                return YES;
            } else {
    

    I haven’t tested this second part but it should work just fine.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently using jquery in my website but when i try to open this
Im currently using a plugin called Cycle for jQuery and would like to tweak
I am currently using matplotlib.pyplot to create graphs and would like to have the
Currently using MySQL version 5.1.6 This is my first real world build and so
Currently using: @^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;%\$#_]*)?$ How can i make http:// not compulsory but if it does
Im currently using a UITableView like any other, and I am researching into the
I am currently using this syntax in my Django 1.1.2 template: {% ifnotequal myvalue
I'm packaging a mobile website (over the network) in PhoneGap and would like to
Currently using Telerik ASP .NET MVC Controls version 2011.2.712 Hello all, I am trying
Im currently using the Barcode Scanner from the open source library Zxing in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.