• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Run Javascript Function From Objective-C.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Run Javascript Function From Objective-C. (From: Philip Juel Borges <email@hidden>)
 >Re: Run Javascript Function From Objective-C. (From: Izidor Jerebic <email@hidden>)

  • Prev by Date: Stopping ODQuery (OpenDirectory Framework) takes a long time (unusable)
  • Next by Date: One-liner to check existence of image
  • Previous by thread: Re: Run Javascript Function From Objective-C.
  • Next by thread: Re: Run Javascript Function From Objective-C.
  • Index(es):
    • Date
    • Thread