Output Javascript's"Alert" into Xojo.

hi everybody.

These days I written a JavaScript code that Helps me to do the following:

  1. I have a website that I need to do webscrapping, I do querys on this site.
    Overtime that I make a Query and press the Search button Shows a “Wait a Moment message”. After the query has results, it shows a table with results, If not,shows a label with “No results”.

Basically It has two controls or panels as they call it.

  1. ctl00_MainContent_PnlNoResultados
  2. ctl00_MainContent_PnlResultados

by default both have hidden by CSS Attributes: “display:none”.

So for got the results, I proceed to use a SetTimeOut for wait that these controls change their states to “Visible” or “display:inline”.
And It works ok.

Thats the conditions that needs to meet:
If ctl00_MainContent_PnlNoResultados is Visible, Then Alerts “No available Results”
If ctl00_MainContent_PnlResultados is Visible, Then Alerts “Results Available”.

At this point everything its ok.
I’m doing this on a HTMLViewer.ExecuteJavascript().

There is the code:

Dim Banner As String= "setDDLday();" _ +"var HayDescargaSiONo;"_ +"function setDDLday() {" _ +" setTimeout(VerificaResultados,100);"_ +" function VerificaResultados() {" _ +" if ($('#ctl00_MainContent_PnlNoResultados').css('display') != 'none') {" _ +" alert('No Hay Resultados');"_ +" } else if ($('#ctl00_MainContent_PnlResultados').is(':visible')) {" _ +" alert('Si Hay Resultados');" _ +" } else {" _ +" setTimeout(VerificaResultados,100);" _ +" };" _ +" };" _ +"}"_ HTMLViewer1.ExecuteJavaScript(Banner)

But the really big problem “FOR ME” is how can I output the result displayed by the Alerts messages to Xojo, in order to use the results on Xojo?
Is this possible?

Thanks

Looking at the forum and the Web I found that WebUIDelegateClass would be my friend on Mac, but I don’t know if theres something similar for windows.

[quote=254151:@Gerardo García]But the really big problem “FOR ME” is how can I output the result displayed by the Alerts messages to Xojo, in order to use the results on Xojo?
Is this possible?[/quote]

You should really learn to search the forum before asking questions. There are dozen of threads about that very topic.

Here is one of the links obtained with a search with “Javascript return” :
https://forum.xojo.com/3597-javascript-variables/0

Also, read WebSDK.pdf, in the Extras/WebSDK folder, next to the Xojo executable. WebSDK control wrapper has a feature to return a value to Xojo from a script.

There is not.

That is only for Xojo Web. Sorry.

The best way in Desktop is to use StatusChanged, TitleChanged or CancelLoad.

[quote=254168:@Michel Bujardet]That is only for Xojo Web. Sorry.

The best way in Desktop is to use StatusChanged, TitleChanged or CancelLoad.[/quote]
In Fact,Thanks For Mac I’m Using TitleChanged.

For Windows I use the MBS Plugins:

HTMLViewer1.IERunJavaScriptMBS(Function) Result = HTMLViewer1.IETitleMBS

[quote=254291:@Gerardo García]In Fact,Thanks For Mac I’m Using TitleChanged.

For Windows I use the MBS Plugins:

HTMLViewer1.IERunJavaScriptMBS(Function) Result = HTMLViewer1.IETitleMBS[/quote]

The main advantage of TitleChanged is that you can return several variables at any time, while WebUIDelegateClass and IERunJavaScriptMBS only return once.