On Aug 5, 2009, at 2:08 PM, Development wrote:
I'm trying to get a value for a specific variable to tell if a
transaction is complete on iphone. In the didFinishLoading delegate
method I have placed this code:
NSString * aString =[theWebView
stringByEvaluatingJavaScriptFromString
:@"document.getElementsByName(\"encrypted\").value"];
NSLog(@"AString: %@",aString);
The string is empty. I get nothing although I clearly have a field
variable named encrypted in the html source of the page it is
loading, and that field has a value because I have assigned it the
value "Success!"
So I am concerned... What am I doing wrong?
Set a break point in the debugger at that point.
Use gdb to make sure that things are actually like you expect them to
be, using a series of "po" commands calling [theWebView
stringByEvaluatingJavaScriptFromString:] with various queries.
Since stringByEvaluatingJavaScriptFromString doesn't do any attempt at
stringification of objects (and will return an empty string instead
something like "[DOMElement]"), you'll probably want to do it
manually, such as:
po [theWebView stringByEvaluatingJavaScriptFromString @"'' +
document.getElementByName('encrypted')"]
That will show you if there really is something there like you expect.
Most likely, you're calling it at the wrong time, before the content
has been fully loaded/rendered...
Glenn Andreas gandr...@gandreas.com
<http://www.gandreas.com/> wicked fun!
Mad, Bad, and Dangerous to Know
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com