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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:59:09+00:00 2026-05-20T05:59:09+00:00

I’m developing an iphone app that makes use of of a UIWebView to display

  • 0

I’m developing an iphone app that makes use of of a UIWebView to display an HTML5-based page. The requirements include:

1: The page needs to render inline SVG.
2: The page needs to access localStorage.

To get the mime type right so the inline SVG would work, I first tried using the code below to populate the web view:

NSString *resourcePath = [[NSBundle mainBundle] resourcePath]; 
NSURL *baseURL = [[NSURL alloc] initFileURLWithPath:resourcePath];
[self.webView loadData:htmlData 
 MIMEType:@"application/xhtml+xml"  
 textEncodingName:@"UTF-8" 
 baseURL:baseURL];

However, when trying this technique, I kept elliciting SECURITY_ERR exceptions when trying to access local storage:
W3C documentation on localStorage and SECURITY_ERR

I found someone who had the same issue, and they believed it was due to the domain origin:
Post covering issues with UIWebView and localStorage access issues

They resolved their issue by using an NSURLRequest instead:

NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:[path stringByAppendingString:@"path and file name of the file"]];
NSURLRequest *request = [NSURLRequest requestWithURL:baseURL];
[webView loadRequest:request];

This does seem to resolve my localStorage issues, however this breaks my SVG because I’m not aware of how to explicitly set the mime type in this case.

So, the question is, how do I load the data with the correct mime type for inline svg while still keeping the document’s origin compliant with localStorage requirements?

Thank you for your help 🙂

  • 1 1 Answer
  • 2 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-20T05:59:09+00:00Added an answer on May 20, 2026 at 5:59 am

    I felt reinvigorated today, in large part thanks to @JimDusseau providing a novel attempt to solve the problem (I must confess I’d given up on getting this to work.) Unfortunately, Jim’s approach works for the request, but it still had no effect on the response.

    I then Googled for 2 hours trying to find other options, one of which was trying to associate a mime type with particular file extensions, etc.

    All of this Googling proved fruitless, but it did trigger a vague memory of another file extension…

    .xhtml

    Could using this file extension cause the request to be handled with the appropriate mime type? My heart started pounding, I could feel the blood coursing through my veins, and, with great anticipation, I made the edit and rebuilt the project to find that [drumroll]…

    YES! YES! YES! The iphone treats the response with the appropriate mime type AND keeps the document origin happy for localStorage.

    Here’s the working code:

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"xhtml"];
    NSURL *baseURL = [NSURL fileURLWithPath:filePath];
    NSURLRequest *request = [NSURLRequest requestWithURL:baseURL];
    [webView loadRequest:request];
    

    Simple, yet elusive (until now.)

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I've got a string that has curly quotes in it. I'd like to replace

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.