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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:21:50+00:00 2026-05-27T05:21:50+00:00

There appear to be several suggestions, but nothing seems to work: https://stackoverflow.com/search?q=UIWebview+load+local+css+remote+website&submit=search What I

  • 0

There appear to be several suggestions, but nothing seems to work:
https://stackoverflow.com/search?q=UIWebview+load+local+css+remote+website&submit=search

What I am doing is loading 2 JavaScript files after a website has loaded.

The first one sets some properties and the second one goes through the DOM and alters the page formatting. I can verify that the link tag with the correct href is inserted into the DOM by looping through the link elements. The processing done by the 2nd script also runs correctly.

I can also set this up as a bookmarklet in a browser and this works on all browsers I’ve tested so far. The CSS only doesn’t take in a UIWebView.

Has anyone to got this to work recently?

Obj-C

NSString * css = [[NSBundle mainBundle] pathForResource:@"mycss" ofType:@"css"];
NSURL * cssURL = [NSURL fileURLWithPath:css];
[_webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"appendCSS('%@')", cssURL]];

JavaScript

function appendCSS(csshref)
{
    //alert(css);
    var css=document.createElement('link');
    css.rel='stylesheet';
    css.href=csshref;
    css.type='text/css';
    css.media='all';
    //Try a couple of things. Appear to be equivalent.
    //document.documentElement.appendChild(css);
    document.getElementsByTagName('head')[0].appendChild(css);
}
  • 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-27T05:21:51+00:00Added an answer on May 27, 2026 at 5:21 am

    A remote webpage can’t access local files. (The URL you’re using is to a file in your bundle.)

    Can you host the CSS elsewhere? Otherwise, you might just load the CSS from the file yourself and insert it into the DOM in a style element.

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

Sidebar

Related Questions

The Maven Buildnumber plugin doesn't appear to work with GIT yet. Is there a
After reading several other blog posts and articles (references found below) there appear to
We have submitted our app several times to search and it still doesn't appear
There appear to be a lot of unnecessary frameworks loading into my iPhone app.
There does not appear to be any good software to mount an FTP to
There doesn't appear to be a generic implementation of OrderedDictionary (which is in the
Are there any issues with changing elements which will appear on a web page
Is there a straighforward way to set additional text to appear in a tooltip
Is there a way to get some text to appear only when the [draft]
I've searched several threads and bug reports, but couldn't find a solution. I changed

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.