0

I am developing a COCOA application. It's a requirement of the application to load HTML page from a local directory. The HTML page includes links to many resources such as images, JavaScript, XML and CSS file. Hence it's more like a local website without any server. How can I achieve this using WebView control? I am developing application for Mac OS X.

Any help would be highly appreciated, Farooq-

Farooq Zaman
  • 465
  • 1
  • 6
  • 20

2 Answers2

1

You can simply use this code -

[[yourWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:pathOfLocalWebPage]]];

Hope this helps :)

Devarshi
  • 15,962
  • 10
  • 64
  • 122
0

Swift 3:

let urlpath = Bundle.main.path(forResource: "index", ofType: "html");
let requesturl = URL(string: urlpath!)
let request = URLRequest(url: requesturl!)
webView.mainFrame.load(request)
Scinfu
  • 1,008
  • 13
  • 17