2

I am loading a webpage on to my UIWebView. The webpage loaded successfully and the buttons on the webpage working fine. But I am unable to see the alerts on the webpage which should pop-up when i enter wrong text into the text box on webpage.

How to allow the alerts to displayed.

Please help me. thank you

This is my code:

[webView loadRequest:[NSURLRequest requestWithURL: 
    [NSURL URLWithString:@"http://DUMMYURL.com/"]]]; 
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
kumar
  • 453
  • 1
  • 5
  • 26
  • some important questions to answer here would be: do the alerts appear in Safari in your simulator and/or on the device? also, do all alerts or only some alerts not appear? – Michael Dautermann Jun 18 '12 at 11:07
  • am loading the webpage into webview of my app. initial alert is displaying but not rest of the alerts – kumar Jun 18 '12 at 11:28
  • 1
    The fact that one alert will display but not others strongly indicates there is simply a logic error with your web page and nothing to do with UIWebView (which ordinarily has no problem displaying JS alerts). Why don't you post it. And you didn't answer the question about how the page behaves in Mobile Safari. – Gruntcakes Jun 18 '12 at 14:23

1 Answers1

0

Here I need one more clarification. That is, 1.How you are handling the alerts? is that is from middle tire? or 2.are you showing in your web view delegates by getting the reference identifier which you have already given in HTML?

If you are following the second step, you can get the reference tag in the web view delegate method. that is,

- (BOOL)webView:(UIWebView *)webView1 shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSString *referenceString = [[[request URL] absoluteString] lastPathComponent];
}

So, Here the "referenceString" shows the reference tag which you have assigned for selection in HTML. this should be unique.

Here you can compare the reference tag and generate the alert.

I think this can be useful.

Millie Smith
  • 4,536
  • 2
  • 24
  • 60
Rajesh
  • 483
  • 2
  • 8