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

  • Home
  • SEARCH
  • 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 6023633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:02:04+00:00 2026-05-23T04:02:04+00:00

I need to know what should be done to use JavaScript in a HTML

  • 0

I need to know what should be done to use JavaScript in a HTML sitting in UIWebView to notify Objective-C that something has happened?

To be more exact, I’m playing some JavaScript animation in HTML and I need to alert the Objective-C code that the animation has ended.

  • 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-23T04:02:05+00:00Added an answer on May 23, 2026 at 4:02 am

    There seems to be no official method of doing this. However, the standard workaround involves reading and parsing incoming URL requests, basically rolling your own serialized messaging protocol. The message handling should be done in the webView:shouldStartLoadWithRequest:navigationType method of your view controller.

    Note: there are several free libraries (PhoneGap, QuickConnect, JS-to-Cocoa Bridge) which wrap this functionality (plus do a whole lot more). To reinvent the wheel (or know why it’s round, so to speak), read on.

    From JavaScript, you will invoke the callback by attempting to navigate to a new URL:

    // In JavaScript
    window.location = 'myapp:myaction:param1:param2'; // etc...
    

    In Objective-C, implement the UIWebViewDelegate protocol in your .h file:

    // In your header file
    @interface MyAppViewController : UIViewController <UIWebViewDelegate> {
      ...
    }
    @end
    

    Next, implement the method in your .m file:

    // In your implementation file
    -(BOOL)webView:(UIWebView *)webView2
           shouldStartLoadWithRequest:(NSURLRequest *)request
           navigationType:(UIWebViewNavigationType)navigationType
    {
      // Break apart request URL
      NSString *requestString = [[request URL] absoluteString];
      NSArray *components = [requestString componentsSeparatedByString:@":"];
    
      // Check for your protocol
      if ([components count] > 1 &&
          [(NSString *)[components objectAtIndex:0] isEqualToString:@"myapp"])
      {
        // Look for specific actions
        if ([(NSString *)[components objectAtIndex:1] isEqualToString:@"myaction"])
        {
          // Your parameters can be found at
          //   [components objectAtIndex:n]
          // where 'n' is the ordinal position of the colon-delimited parameter
        }
    
        // Return 'NO' to prevent navigation
        return NO;
      }
    
      // Return 'YES', navigate to requested URL as normal
      return YES;
    }
    

    Two important notes:

    1. Context: navigating to myapp:whatever will (of course) fail under any other context. Keep this in mind if you’re loading cross-platform pages.

    2. Timing: if a second window.location = call is made before the first returns, it will get ‘lost.’ So, either lump your calls together, manually delay execution, or implement a queue which combines the above with JS queries into Objective-C objects.

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

Sidebar

Related Questions

This seems like it should be something I already know. We need to run
I am starting with c++ and need to know, what should be the approach
Need to know this so that i could send DTMF and that is going
I'm using javascript and jQuery. I have a problem that my web app has
THE QUESTIONS: What I do need to know is how I should go about
I need to create web-page that has a button. After pressing the button I
Hi I am interested in learning SQL databases something I should have done a
I need to know about Epoll On linux System. Could you recommend manual or
I need to know how the performance of different XML tools (parsers, validators, XPath
I need to know how much space occupies all the databases inside an SQL

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.