Mac: Hide webview until loaded
This commit is contained in:
parent
0fe96ad7ed
commit
13ca583e22
1 changed files with 7 additions and 0 deletions
|
@ -17,6 +17,7 @@ class ViewController:
|
|||
|
||||
webView.navigationDelegate = self
|
||||
webView.uiDelegate = self
|
||||
webView.isHidden = true
|
||||
|
||||
clearWebViewCache()
|
||||
|
||||
|
@ -154,8 +155,14 @@ class ViewController:
|
|||
NSLog("webView didFinish navigation: \(webView.url?.absoluteString ?? "")")
|
||||
// Disable right-click menu
|
||||
webView.evaluateJavaScript("document.body.setAttribute('oncontextmenu', 'event.preventDefault();');", completionHandler: nil)
|
||||
webView.isHidden = false
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
|
||||
webView.isHidden = false
|
||||
}
|
||||
|
||||
|
||||
func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
|
||||
if let frame = navigationAction.targetFrame,
|
||||
frame.isMainFrame {
|
||||
|
|
Loading…
Reference in a new issue