Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set contents of webview to html string (cocoa)

Is there any easy way to set the contents of a webview to an HTML string (without having to load a file)?

Thanks

like image 842
N S Avatar asked Nov 05 '09 04:11

N S


2 Answers

[[webView mainFrame] loadHTMLString:htmlString baseURL:someURL];

(Where someURL is used to resolve relative URLs in the HTML source.)

like image 67
Wevah Avatar answered Nov 13 '22 06:11

Wevah


[webView loadHTMLString:yourString baseURL:[[NSBundle mainBundle] bundleURL]];

You can use [[NSBundle mainBundle] bundleURL] if you desire to load stylesheets(css) or javascripts(js) files that are in your resources dir, if not, just use nil

like image 23
Megarushing Avatar answered Nov 13 '22 06:11

Megarushing