I am new to the Mac world.
I need to create an application that can extract information entered on a web page from text fields. My application will load a webpage hosted somewhere, and inside the webpage there will be a series of text fields and a submit button. After clicking the button, I should be able to read the information entered into the text fields of this web page.
I have the code as follows:
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{
if (aSelector == @selector(showMessage:)) {
return NO;
}
return YES;
}
- (void)showMessage:(NSString *)message
{
DOMDocument *myDOMDocument = [[webView mainFrame] DOMDocument];
DOMElement *contentTitle = [myDOMDocument getElementById:@"TexTest"];
message = [[contentTitle firstChild] nodeValue];
NSRunAlertPanel(@"Message from JavaScript", message, nil, nil, nil);
}
When I launch the application and get into NSRunAlertPanel, it no longer wants to execute.
When I comment out the three lines of the DOM, NSRunAlertPanel displays my message and I can continue.
HTML looks like this:
<body>
<h1 id="contentTitle">Some kind of title</h1>
<div id="main_content">
<p>Some content</p>
<p>Some more content</p>
</div>
<div>
<input id="TexTest" value=" " type="text">
</div>
<div>
<input id="message_button" value="Show Message" onclick="window.AppController.showMessage_('Hello there...');" type="button">
</div>
</body>
Can anyone help with this issue?