Run javascript on Mac

Hello guys,

I’m working on a program ( Just for MAC ) that has to run some Javascripts, do it with Applescript I know but would like to know how to run natively with these Javascripts XOJO, something like “executejavascript” that works with Web Applications.

Any help will be appreciated,

Thanks to all.

You can’t use AppleScript on a client of a Web App.

You’ll need a JavaScript engine of some sort. For example:

You can use an HTMLViewer to run your JS code, but there are some limits… If you have MBS I believe that overcomes most (if not all) of the short comings of the built-in HTMLViewer… (I do not use MBS, just remember reading about it)

Yes, we have plugin methods to run javascript in htmlviewer on desktop app.

Thank you all for the support.

Sean Shao, could tell me more about “HTMLViewer to run your JS code” ?

Because I never work with HTMLViwer.

and there’s the 100% unsupported and really hacky way of using

but I never mentioned it right ? :stuck_out_tongue:

Although you could declare into JavaScriptCore and use those supported functions.

ok, I try !

You can use HTML Viewer in a desktop App and can start JavaScript function in OnLoad. You can use the return value of your JavaScript then write this in title for example and use TitleChanged Event in Xojo. That it relly hacky and complex way. ;-). But that is possible,

Without Xojo you can take a look for Tide or other Frameworks. I don’t test this deeper. Perhaps you found a way with Xojo. Or Nodes.js? Perhaps oversized but I hear give it bridges to many language (.Net, T-SQL and i don’t know what else.) Perhaps the other way is possible for get values from Nodes.js :wink: ;-). Good luck.

And I think that is possible to use JavaScript instead AppleScript on Mac OS X. The Architecture supports that or supported that. I mean for a few years in every case JavaScript supported instead of AppleScript. I don’t know this works actually. Look like this:

Walter Zeidler,

I’ll take a look, I thank the support.

You can do lots of interesting things just using the built-in HTMLViewer to do all your JavaScript… The one limitation that still bothers me is the lack of getting return data from the JavaScript, but you can always use either the document.title or window.status hacks to get data back to Xojo… I personally use document.title as the name of my “event” and window.status to handle the data back from JavaScript (window.status can handle lots of data whereas document.title is limited to the amount of data)… You can also use the MBS plugins to handle JavaScript returns as well…

As always, use the WebKit renderer so you get the same results cross-platform (yes, it adds to the bulk of the Windows app, but it is worth it)…

Shao thanks for the help, I’m really grateful to you!