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
  • 495
  • 1
  • 6
  • 21

2 Answers2

1

You can simply use this code -

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

Hope this helps :)

Devarshi
  • 16,440
  • 13
  • 72
  • 125
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,081
  • 13
  • 18