javascript in XOJO

My apps is almost done BUT
im using applescript to reach Safari Form page
If i’m implementing HTML viewer inside my XOJO window1
Is there a way to send javascript to Xojo internal web browser
Im using applescript to read/write to safari and it look like

do JavaScript "document.getElementsByName('customercustomer')[0].selectedIndex=" & v01customer & "" in document 1

Thanks

http://documentation.xojo.com/index.php/HTMLViewer.ExecuteJavaScript

Jason is right…executejavascript is the way to go :slight_smile:

Shame on me (on docs.xojo)
I’v assuming is was more complicate…
For a MAC guy…(like Pc activex restriction) etc etc
thanks

i’m back with same question…More precise
Can i get return value of webpage
I need to get the content of dropdownmenu of web-form to replicate in my desktop app
( Like a synchronization ) to be sure that i have same item to choose
(the dropdownmenu of webform) could change at any time… so i cant hardcoding the item
i have a loop who tell applescript to get it and return each element
Is this could be done with HTMLViewer1.ExecuteJavaScript
Like Dim t as text = HTMLViewer1.ExecuteJavaScript"document.getElementsByName("menu")[0].selectedIndex=" loop ""
I know it return nothing
Thanks

The only way I have found at getting results from the HTMLViewer back to Xojo is to use the “window.status” kludge…

yes i’v read about getting all code source then i could apply regex to pull out the info
BUT i wont do it that way
the post is still alive

HTMLViewer1.ExecuteJavaScript"window.status = document.getElementsByName("menu")[0].selectedIndex=" loop ""

and then get the result in the StatusChanged event… Seeing as I could use this functionality, I will either be looking at how to do it with declares or learning how to code plugins to do this…

Thanks to diging the issue
I’v try the StatusChanged event with window.status BUT
it return only the number of listindex (that i just send myself to the webpage)
Not the text whos attach to listindex
Even in applescript it takes two query to pull out the text (the selectedIndex and the options) together as one string (fullx)

do JavaScript "var indexx=document.getElementsByName(" & "'" & idz & "'" & ")[0].selectedIndex=" & I & "" do JavaScript "var optionx=document.getElementsByName(" & "'" & idz & "'" & ")[0].options;" set fullx to do JavaScript "dropdowntext=optionx[indexx].text;"
I’ll continue to follow the statusChanged event with other javascript query…to see what coming out
Theres not much info on these feature

i’v got it!!
in statuschanged event

newstatustext =  newStatus

And a PushButton to test

Dim i As Integer For i = 0 To 20 HTMLViewer1.ExecuteJavaScript"window.status = document.getElementsByName('customercustomer')[0].options[" + str(i) + "].text;" MsgBox newstatustext Next
when the loop reach the end of the dropdownmenu… it repeat the last item until the end of i
I think if i got twice same answer, that will stop the loop
Is it make sense??

No…better than that
always with the windows.status i can get the lenght

HTMLViewer1.ExecuteJavaScript"window.status = document.getElementsByName('"+ idz(a) +"')[0].length;"
HTMLViewer1.ExecuteJavaScript"window.status = document.getElementsByName('"+ idz(a) +"')[0].options[" + str(i) + "].text;"

with the content as text and the lenght i have everything i need
Thanks Shao for the lead to window.status & statuschanged