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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:12:28+00:00 2026-05-24T19:12:28+00:00

I have to do some complex work with a UIWebView and Javascript and always

  • 0

I have to do some complex work with a UIWebView and Javascript and always get problems when I try to insert complex Javascripts involving JQuery and HTML Snippets that contain JavaScript themselves. I never seem to have enough quote and single quote signs and putting in script elements is kinda painful.

I there a magic Objective-C snippet, or an easier copy-pasteable way of using more complex scripts that you use for such tasks?

EDIT: To explain a bit more, I have big snippets of HTML (containing also Javascript and stuff like <a href="javascript:doSomething('stupid')")> that I need to put in the DOM via JavaScript, after I load a website in an UIWebView.

My approach now is to put the HTML stuff into files, rewrite them so that I for example have ‘stupid’ in a JS-variable so I don’t need additional single quotes, put placeholders into place like ###placeholder1###, load that file into an NSString and replace those placeholders by dynamic data generated in my app via html = [html stringByReplacingOccurrencesOfString:@"###placeholder1###" withString:dynamicStuffHtml];. The dynamic data before contains no single quotes, other than in the text-content, for which I replace the single quotes with the HTML-encoded &#39;.

Then I try to put that whole string into the DOM by doing this:

NSString* javascript = [NSString stringWithFormat:@"%@%@%@",@"jQuery('.focus_box').first().before('",html,@"');"];
[webView stringByEvaluatingJavaScriptFromString:javascript];

This works for easy and short examples (for example when I put in short paragraphs or simple HTML), but for the full-blown approximately 50-60 lines HTML snippet, it just doesn’t work. Additionally, all that editing, replacing, patching and stuffing made me think that maybe someone using UIWebViews and JavaScript has a better solution that is known to work.

EDIT AGAIN: I started a bounty, because I cannot believe that there’s so few usages of UIWebView that nobody has an answer to this, or already has a big private Tools-class to handle such more complex JavaScript interaction where big chunks of HTML can be included without a reload. 🙂

  • 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-24T19:12:28+00:00Added an answer on May 24, 2026 at 7:12 pm

    To load some file form inside UIWebView, do the following

    <script language="javascript" type="text/javascript">
    var bundlePath = "here_goes_full_path_to_your_bundle"; 
    // It should be something like file:///var/.../YouApp.app 
    // Set it from your code
    
    jQuery.get(bundlePath + "/someFile.html", function(data) {alert(data);});
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some complex stored procedures that may return many thousands of rows, and
I'm using .NET 3.5. We have some complex third-party classes which are automatically generated
Greetings, I'm working on a JS-based application that does some complex work and logs
At work I've been dealing with some complex forms (publish pages of Symphony )
I have some problems when I want to use implicit methods to convert a
I'm working on a new project which has some complex javascript. I can't post
I have some fairly complex libraries that interconnect with each other to do some
I'm trying to create a controller for a custom complex object but have some
I have some UI in VB 2005 that looks great in XP Style, but
I have some ASP.NET web services which all share a common helper class they

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.