0

I have a webView and when you open one view it takes the webView and gets the html (through javascript) and the problem is that when I try to load the edited html, it comes up funny looking, like it is missing the images and its mostly text and not as nice. For example: If I go on Yahoo Mobile and I change the Today Tab to say say lets say Hi, then it all comes out in one column as hyperlinks instead of with the big search bar, news in the middle etc.

Heres My Code For Retrieving The HTML:

-(IBAction)recieveHTML:(id)sender {
htmlView.hidden = NO;
NSString *html = [webView stringByEvaluatingJavaScriptFromString:
                  @"document.body.outerHTML"];
NSString *query = [html stringByReplacingOccurrencesOfString:@">" withString:@">\n"];
htmlTView.text = query;
universalURL = url.text;

}

Heres My Code For Reloading The HTML:

-(IBAction)changeHTML:(id)sender {
[htmlTView resignFirstResponder];
NSString *query = [htmlTView.text stringByReplacingOccurrencesOfString:@">\n" withString:@">"];

[self.webView loadHTMLString:query baseURL:[NSURL URLWithString:universalURL]];
htmlView.hidden = YES;

}

Does anyone know why this is happening?

4

1 回答 1

0
universalURL

这个值是你认为应该是的值吗?听起来它不是,因此,图像和样式表的路径不再有效。

如果您只是在操作字符串,那么最好只使用 javascript 而不是重新加载 html。

于 2012-08-31T02:50:24.940 回答