如何在WebView runJavascriptAlert OSX中停止重复警报

如何在WebView runJavascriptAlert OSX中停止重复警报,javascript,objective-c,macos,webview,alert,Javascript,Objective C,Macos,Webview,Alert,我已经创建了下面的runJavaScriptAlertPanelWithMessage函数,该函数显示javascript警报,但是我想防止恶意网站能够不断发出警报。我尝试过各种各样的事情,但没有任何运气,所以我希望有人能对我如何做到这一点有想法 - (void)webView:(WebView *)wv runJavaScriptAlertPanelWithMessage:(NSString *)msg initiatedByFrame:(WebFrame *)frame { NSString

我已经创建了下面的runJavaScriptAlertPanelWithMessage函数,该函数显示javascript警报,但是我想防止恶意网站能够不断发出警报。我尝试过各种各样的事情,但没有任何运气,所以我希望有人能对我如何做到这一点有想法

- (void)webView:(WebView *)wv runJavaScriptAlertPanelWithMessage:(NSString *)msg initiatedByFrame:(WebFrame *)frame {
NSString *host = [[NSURL URLWithString:[wv mainFrameURL]] host];
NSString *t = NSLocalizedString(host, @"");
NSString *defaultButton = NSLocalizedString(@"OK", @"");


self.currentJavaScriptAlert = [NSAlert alertWithMessageText:t defaultButton:defaultButton alternateButton:nil otherButton:nil informativeTextWithFormat:msg];
[currentJavaScriptAlert beginSheetModalForWindow:[[frame webView] window] modalDelegate:self didEndSelector:@selector(alertPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL];
}