• 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: Getting WebView and JavaScript to communicate. MFC can do it.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting WebView and JavaScript to communicate. MFC can do it.


  • Subject: Re: Getting WebView and JavaScript to communicate. MFC can do it.
  • From: Daniel Jalkut <email@hidden>
  • Date: Wed, 11 Jan 2006 01:45:23 -0500

Hi Theodore - I think what you want is the (relatively) recently added "WebScriptObject" functionality on WebView.

Search on "WebScriptObject" and if none of that makes sense try "WebScriptObject Dashboard" because Dashboard widgets use a very concrete example of setting Cocoa objects as WebScriptObject properties that can then be accessed from within the JavaScript context.

The gist is that you wait for your WebView to "have a web script object available," and then you can simply "setValue" on it to represent your Cocoa object in the JavaScript namespace with a specified name.

Daniel

On Jan 10, 2006, at 5:15 PM, Theodore H. Smith wrote:

Hi people,

I've got a WebView control displaying some web pages containing some complex JavaScripts.

I'm trying to get JavaScript to be able to ask my app for a string, and then also to be able to tell the app to store a string. So Javascript like this:


window.external.CB_SetValue(dataElementName, theNewValue);

value = window.external.CB_GetValue(dataElementName);

would be able to access data from my app.

How can I do this in WebView?

It's possible to do in MFC, although complicated. MFC allows you to hook into the JavaScript interpreter and return values or get values.

I looked through the documentation but saw no evidence of an inbuilt way to do this.

Is it possible that I *can't*? If so, is there a work around? Maybe some kind of cookies? The data does not need to be generated at realtime. The data is prefs, so the prefs are loaded before the javascripts are loaded, and saved after the html closes.

I know very little about WebView, except that it should be quite powerful seeing as Safari uses it.

Thanks for your help everyone!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Getting WebView and JavaScript to communicate. MFC can do it.
      • From: "Theodore H. Smith" <email@hidden>
References: 
 >Getting WebView and JavaScript to communicate. MFC can do it. (From: "Theodore H. Smith" <email@hidden>)

  • Prev by Date: Re: Crash in AppKit.subproj/NSViewHierarchyLock.m:444
  • Next by Date: Drag and Drop while Application Modal Window is active
  • Previous by thread: Getting WebView and JavaScript to communicate. MFC can do it.
  • Next by thread: Re: Getting WebView and JavaScript to communicate. MFC can do it.
  • Index(es):
    • Date
    • Thread