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 6085863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:41:13+00:00 2026-05-23T11:41:13+00:00

When writing a iPhone / iPad app with a UIWebView, the console isn’t visible.

  • 0

When writing a iPhone / iPad app with a UIWebView, the console isn’t visible.
this excellent answer shows how to trap errors, but I would like to use the console.log() as well.

  • 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-05-23T11:41:13+00:00Added an answer on May 23, 2026 at 11:41 am

    I have a solution to log, using javascript, to the apps debug console.
    It’s a bit crude, but it works.

    First, we define the console.log() function in javascript, which opens and immediately removes an iframe with a ios-log: url.

    // Debug
    console = new Object();
    console.log = function(log) {
      var iframe = document.createElement("IFRAME");
      iframe.setAttribute("src", "ios-log:#iOS#" + log);
      document.documentElement.appendChild(iframe);
      iframe.parentNode.removeChild(iframe);
      iframe = null;    
    };
    console.debug = console.log;
    console.info = console.log;
    console.warn = console.log;
    console.error = console.log;
    

    Now we have to catch this URL in the UIWebViewDelegate in the iOS app using the shouldStartLoadWithRequest function.

    - (BOOL)webView:(UIWebView *)webView2 
    shouldStartLoadWithRequest:(NSURLRequest *)request 
     navigationType:(UIWebViewNavigationType)navigationType {
    
        NSString *requestString = [[[request URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
        //NSLog(requestString);
    
        if ([requestString hasPrefix:@"ios-log:"]) {
            NSString* logString = [[requestString componentsSeparatedByString:@":#iOS#"] objectAtIndex:1];
                                   NSLog(@"UIWebView console: %@", logString);
            return NO;
        }
    
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an app for the iPad/iPhone and am looking for a suggestion
I'm writing an iPhone/iPad app, and I'm wondering if future updates will wipe the
I'm writing an iPhone App that relies on getting the device location. Management have
I am writing an iPhone app – a client for some social network. The
I'm writing an iPhone app for a client, and they have requested a feature
I really would like to write an app or apps for iPhone / iPad.
I've been researching writing an app for iPhone. I really like the look of
I'm thinking of writing an iPhone/iPad application to emulate a MIDI controller. I know
Is there any reference about writing an application on iPad/iPhone to show HTML5 content
Are there any limitation in writing universal application for iPhone and iPad ? (or

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.