Call Javascript Function

I have a web application where I have embedded a webhtmlviewer with HTML code and a few JS functions. These JS functions are both embedded and come from another site. I am attempting to call a JS function from a XOJO webbutton action handler. I only push this Xojo button after I now the whole webhtmlviewer is displayed.

I get the error “Could not execute returned javascript: wwt is not defined”. wtt is the JS function I’m trying to call. I understand this means that it can not see the wtt function…but it is there because I can call it from a button I code directly into the webhtmlviewer.

Any suggestions on how I can access this wtt function from a Xojo button?

Unless the content of the webHTMLViewer is on the same site as your app, that won’t be permitted, since the content is into an iFrame (the WebHTMLViewer).

Since you say the content comes from another site, it simply won’t be possible.

You’re trying to XSS, which is blocked by your browser.
You should serve the website inside the webhtmlviewer from your webapplication.

See this thread from a few months back. I asked the same question: https://forum.xojo.com/41886-executejavascript-error/

The moment I served the html pages from within my webapplication, everything worked like a charm.

If you have no control over the content served (i.e.: It’s someone elses website), you’re out of luck. It won’t be possible. And that’s no limitation of Xojo whatshowever. That’s just the way internet works (is secured).

@Mathias Maes , I took a look at that stream before submitting my question and I didn’t think it applied. Going through it again, I might have been wrong. I will try to host the JS file on my server to see if that gets me past the issue.

The HTML is on my server, while the JS and images are on another one (worldwidetelescopes.org). I’ll try and move the JS to my server to see if that helps.

Unfortunately after a bunch of testing, I’m unable to place the JS on my server. This is because some of the information that is provided is dynamic (comes from a .Net application on World WideTelescopes.org). I’m going to have to keep digging.

You should ask them if they have an API to get the data you want. Then you’d be able to use and display it however you like.

They do have a API that is javascript based. My problem is I need to interact with their information (star image) by doing a search from our database that has almost 9000 records…and I don’t want the users to download all the records in order to see the information for one star. :frowning:

Edit…link to their API: http://www.worldwidetelescope.org/docs/worldwidetelescopewebcontrolscriptreference.html#WebControlDevelopment

That’s not really an API. That is a javascript control you can drop into your page. You would need to use the Web SDK to create a custom control implementing their javascript to use it. Even then it would simply be embedding it with whatever parameters they allow.

@Phillip Zedalis , that is the conclusion I’m coming to as well. My hope was to be able to smoothly move from one star to another, but it looks like that is just not possible. Thank you to everyone who has added their thoughts to this problem.

Robert