in Education by
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! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
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

Related questions

0 votes
    Is it possible to send payload in the GET and DELETE methods?...
asked Jun 23, 2021 in Technology by JackTerrance
0 votes
    I have made a chatroom where users can messages to each other but I want to add a upload file ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    A unit of storage that can store one or more records in a hash file organization is denoted as (a) ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    A unit of storage that can store one or more records in a hash file organization is denoted as (a) ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    The unit of storage that can store one are more records in a hash file organization are (a) Buckets ... from Storage Structure topic in portion Transactions of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    What is hash-collision in Hashtable and how it is handled in Java?...
asked May 27, 2021 in Technology by JackTerrance
0 votes
    Is it possible to refer a property defined in your pom.xml file?...
asked May 4, 2021 in Technology by Editorial Staff
0 votes
    Is it possible to add a file directly to the repository? Which command can be used for this?...
asked Feb 18, 2021 in Technology by JackTerrance
0 votes
    It's a UI path sequence. I am trying to read some URLs from an Excel file.Launch browser Go to URL from file ... save it as a file. Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I have an HTML page that contains some filenames that i want to download from a webserver. I need ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    The face attributes of tag is used to specify the name of the font. True or false no spam messages plzz… Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    how can you insert some other html text file into your one html file? write the tag used for this purpose? Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
0 votes
    The external JavaScript file must contain tag. True or False? A. True B. False...
asked Feb 27, 2021 in Technology by JackTerrance
0 votes
    Hey guys . anyone in class 11 CBSE My Comp. Sci. paper is on monday if anyone has Question paper plzzz send ... .plzzzz..zz .zzzz . Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    _________________ disguises them as legitimate software & appear as Java or Flash Player updates. They will ... Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Oct 31, 2021 in Education by JackTerrance
...