Re: Run Javascript Function From Objective-C.
Re: Run Javascript Function From Objective-C.
- Subject: Re: Run Javascript Function From Objective-C.
- From: Izidor Jerebic <email@hidden>
- Date: Mon, 28 Sep 2009 12:24:52 +0200
On 28.9.2009, at 11:24, Philip Juel Borges wrote:
You need to execute full statement:
NSString *command = [NSString
stringWithFormat:@"goToPage( '%@' );", [sender stringValue]] ;
[theWebView stringByEvaluatingJavaScriptFromString:command] ;
Again, there are no arguments. How could it work? Try this:
[[theWebView windowScriptObject] callWebScriptMethod:@"goToPage"
withArguments:[NSArray arrayWithObject:[sender stringValue]]];
Thanks for your help. But it doesn't work yet. I'm still new to
cocoa, so still learning. I connected the IBAction to the
NSTextField and the test.html is loaded on launch. but nothing
happens. Am I missing something with the NSTextField or something
else?
The above code should work if you have all connections set up correctly.
The simplest way to debug is to just print out what is happening and
check your debug/run console for output. Put this in your methods and
see what happens when you press enter/return in your textfield:
NSLog( @"theWebView = %@, sender = %@, stringValue = %@", theWebView,
sender, [sender stringValue] ) ;
Regards,
izidor
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden