On 5 Aug 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?

I've spent half the morning googling examples, and looking on the developer site and all the examples and information tell me that my code should be good but it isn't.


We have only your word that your HTML and Objective-C are indistinguishable from perfect. If they are perfect, then you don't have a bug at all. If they aren't, then you've given us no way to help you.

Show your code, including the stripped-down HTML tree down to element "encrypted," how you initialize theWebView, and how you load it with the HTML. Tell us things you learned from the debugger, such as what aString _does_ contain, and whether theWebView is nil.

Are you displaying theWebView? If not, have you ascertained whether DOM accessors work on a UIWebView that may not have been rendered? (I confess I don't know, but it's one of the things I'd check.)

        — F

--
Fritz Anderson -- Xcode 3 Unleashed: Now in its second printing -- <http://x3u.manoverboard.org/ >

_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to