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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:25:08+00:00 2026-05-24T11:25:08+00:00

I want to load a html page from a file, and append a hash

  • 0

I want to load a html page from a file, and append a hash tag to it. Is this possible?

I have tried

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"someFile" ofType:@"html"];  
NSURL *fileUrl = [NSURL fileURLWithPath:[filePath stringByAppendingFormat:@"#hashtag"]];
[self.webView loadRequest:[NSURLRequest requestWithURL:fileUrl]];    
NSLog(@"fileUrl = %@, reachable? %d", fileUrl, [fileUrl checkResourceIsReachableAndReturnError:nil]);

but this tries to look for the file someFile.html%23hashtag, which can’t be found. Is there a way to add the hash after the NSURL object is created?

I’ve also tried loading the file into a string and using loadHTMLString:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"someFile" ofType:@"html"];
NSString *fileContents = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:fileContents baseURL:[NSURL URLWithString:@"http://someFile.html#hashtag"]];

Here the hash tag does work, but my javascript references inside the html don’t work. A follow on question from this approach would be, how do I reference javascript files from html loaded in as a string in a UIWebView, ie, what is the base url?

A hack I can think of is to just put all my javascript files inline in the html and load it as a string, but I’m thinking there must be a better way!

  • 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-24T11:25:10+00:00Added an answer on May 24, 2026 at 11:25 am

    I’ve not tried this but how about loading the file normally without the hashtag and implementing the UIWebViewDelegate with something like this?

    - (void)webViewDidFinishLoad:(UIWebView *)webView {
       [webView stringByEvaluatingJavaScriptFromString:@"window.location.href = '#hashtag';"];
    }
    

    References:

    • UIView that takes you to anchor link
    • Programmatically scroll to an Anchor Tag
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to load some images into my application from the file system. There's
I want to load some helper in a model. How to do this? Tried
I want to have a Javascript function load information for an image from an
I have html page which is located on hard disk (in the browser: file:///C:/index.html).
I want to extract a couple of links from an html page downloaded from
I want to load content from a page hosted on another site. The problem
Suppose a HTML document has a iframe. Using javascript,I want to detect ,on load
I want to load 52 images (deck of cards) in gif format from my
I want to load some data from mysql into my cocoa application view before
I want to load defined folders into my website from same system, now I

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.