. h
#import <UIKit/UIKit.h>
@interface UIWebView (Javascriptalert)
-(void) WebView: (UIWebView *) sender Runjavascriptalertpanelwithmessage: (NSString *) message initiatedbyframe: ( Webframe *) frame;
-(BOOL) WebView: (UIWebView *) sender Runjavascriptconfirmpanelwithmessage: (NSString *) message initiatedbyframe: ( Webframe *) frame;
@end
. m
#import "Uiwebview+javascriptalert.h"
@implementation UIWebView (Javascriptalert)
Static BOOL diagstat = NO;
-(void) WebView: (UIWebView *) sender Runjavascriptalertpanelwithmessage: (NSString *) message initiatedbyframe: ( Webframe *) frame{
uialertview* dialogue = [[Uialertview alloc]initwithtitle:nil message:message delegate:nil cancelButtonTitle:@' Okay "Otherbuttontitles:nil, nil];
[Dialogue show];
[Dialogue autorelease];
}
-(BOOL) WebView: (UIWebView *) sender Runjavascriptconfirmpanelwithmessage: (NSString *) message initiatedbyframe: ( Webframe *) frame{
uialertview* dialogue = [[Uialertview alloc] Initwithtitle:nil message:message delegate:self cancelButtonTitle: Nslocalizedstring (@"Okay", @"Okay") otherbuttontitles:nslocalizedstring (@"Cancel" @ "Cancel"), nil ];
[Dialogue show];
while (Dialogue.hidden==no && dialogue.superview!=nil) {
[[Nsrunloop Mainrunloop] rununtildate:[nsdate datewithtimeintervalsincenow:0.01f]];
}
[Dialogue release];
return diagstat;
}
-(void) Alertview: (Uialertview *) Alertview Clickedbuttonatindex: (nsinteger) buttonindex{
if (buttonindex==0) {
Diagstat=yes;
}Else if (buttonindex==1) {
Diagstat=no;
}
}
@end