Interact from html or javascript

Hi,

i have a xojo webapp that have in a webpage a htmlviewer, the xojo webpage have a dialogbox, how i can open this dialog from a html link or button that i have in the documents of the htmlviewer.

Please help.

:wink:

Any help please. I need to shown/open a xojo webpage from javacode using controlid or control name.

Any want can help me please

Well, first of all, you should have put this topic in Web instead of General. Ive moved it so you should get some more specific attention now.

That said, what you are trying to do is not super easy to accomplish. The problem is that the page inside the WebHTMViewer is a completely separate document and shares no code with the main one.

In JavaScript, when you refer to an object in the DOM, you typically use document.getElementById, but in this case, if the code is running from within the HTMLViewer (which is technically an IFRAME), you would need to use “parent.document.getElementById”.

As far as accessing controls by ID, I’m going to give you the standard answer. Don’t do it. We (Xojo) reserve the right to change any part of the undocumented framework and the layout of the DOM at any time as we fix bugs and add other enhancements to the product. Directly accessing the DOM and relying on the current structure may lead to subtle and unexpected bugs in the future. If you need to do this with controls that you create yourself, please use the WebSDK. Documentation and examples are available in the Extras folder next to the IDE.

Maybe if someone said thank you when others do something for him that would encourage others to help… Like when I created a color WebProgressBar for him and the OP did not even care to acknowledge…

You could use SpecialURL to tell your WebApp.

http://mysite.com/cgi-bin/mywebapp/special/whateveryouneedtotellyourwebapp

Michael, i dont know what you talk about. I never use a Progressbar from you. Thank you for the information you provide here but this is the actual method i use in my webapp, the problem that i have with this method is after the app have various user hit this method the specialurl not listen more and i need to restart the webapp. Because of that i need other method to do that.

Gred, i can integrate the html that i have in htmlviewer in a variable and open in a htmlviewer after change some code on the run. But i no found a example of how do the

document.getElementById(‘my webpage controlid’).show

Thanks in advanced

https://forum.xojo.com/15533-webprogressbar-color-gray-in-webdialog

That never function for me. Sorry.

You could at lit have replied then saying so. How do you expect help when you do not have the courtesy to communicate ?

That’s not going to work. You can’t just call Show in javascript and expect it to work the same as xojo code.

Sorry for that my friend. I never go back to this post because when we need to resolve something we spend a lot of hours surfing the internet to get a around of the problem, i im not remember that i post for that here. Thank you again for your time in help me and others.

No, i say like this

ExecuteJavaScript(‘document.getElementById(‘my webpage controlid’)’).show

[quote=139850:@Darwin Quinones]No, i say like this

ExecuteJavaScript(‘document.getElementById(‘my webpage controlid’)’).show[/quote]
Still will not work. ExecuteJavascript doesn’t return anything. It’s asynchronous. But if you’re trying to just do this from Xojo code, you could loop through the controls on a page…

You could use a method like this though…

[code]Function GetControlByName(ControlID as String) As WebControl
for i as integer = 0 to ControlCount-1
dim obj as webobject = self.ControlAtIndex(i)
if obj isa webcontrol then
dim id as string = webcontrol(obj).ControlID
if id = ControlID then
return obj
end if
end if
next

return nil
End Function
[/code]

it would need to be placed on the webpage itself.

Gred, thanks for that, but how i can call this from Java, Or other method to call something that open a webpage from html. Or why the method i use right now (specialurl) lost the listening after various hit to itself.?

I do not understand where is the HTML exactly ? Is it your own webpage ?

Michael, the main menu of my webapp i develop with html and CSS, is a webfile like mainmenu.html, in my xojo webapp the main webpage have a htmlviewer, this htmlviewer load the mainmenu.html

IN the mainmenu.html the buttons options to navigate to other xojo webpages have the href=“mywebapp.cgi/special/myfunctionname_to_load_the web_app_i_need&session_id=jgkhj34769kjgkjg”

This is working. But i want to change that for something more secure because the /specialurl after a while stop listening.

I want to include in my html file some java/php or other method to load the xojo webpages by the controlid or something like that, or resolve the problem of the /specialurl to do not stop listening.

[quote=139943:@Darwin Quinones]Michael, the main menu of my webapp i develop with html and CSS, is a webfile like mainmenu.html, in my xojo webapp the main webpage have a htmlviewer, this htmlviewer load the mainmenu.html

IN the mainmenu.html the buttons options to navigate to other xojo webpages have the href=“mywebapp.cgi/special/myfunctionname_to_load_the web_app_i_need&session_id=jgkhj34769kjgkjg”

This is working. But i want to change that for something more secure because the /specialurl after a while stop listening.

I want to include in my html file some java/php or other method to load the xojo webpages by the controlid or something like that, or resolve the problem of the /specialurl to do not stop listening.[/quote]

Simply use links like href="#OptionOne" and catch them with the session HashTagChanged event.

OK, but how to recover the same session. Example, if the user enter to oneoption and then leave the webpage for otheroption, then when the user goback to the optionone the webpage is refresh completed, I want to restore the previwe state of the webpage for that particular user.

I try in the session open event
dim sessionID as string = (I get the preview sessionid from a urlparameter)
Dim SessionContext As New WebSessionContext(Self.SessionWithIdentifier(SessionID,Request.RemoteAddress))
if Session = nil then
Request.Print(“No session handle”)
Return true
end

But i never recover the preview session.identyfier,

[quote=139969:@Darwin Quinones]OK, but how to recover the same session. Example, if the user enter to oneoption and then leave the webpage for otheroption, then when the user goback to the optionone the webpage is refresh completed, I want to restore the previwe state of the webpage for that particular user.

I try in the session open event
dim sessionID as string = (I get the preview sessionid from a urlparameter)
Dim SessionContext As New WebSessionContext(Self.SessionWithIdentifier(SessionID,Request.RemoteAddress))
if Session = nil then
Request.Print(“No session handle”)
Return true
end

But i never recover the preview session.identyfier,[/quote]

Pardon me, but I fail to understand why you are using an HTML page menu for the navigation inside your app. Would it not be a lot more logical to keep the logic inside your app ?