Showing Webpage with Javascript

Hello,

I need a javascript to open a webpage or a webdialog. Also this script should set a property in the current session.
Can anybody give me advice? Is that possible? I didn’t found any explanations in the Xojo ressources.
It is possible to start a method in the current webpage or session with javascript?

Kind regards
Torsten

What is wrong with show ?

???
I don’t know how to show a webpage. I tried some commands. But it doesn’t work. Is there any advice or examples?

[quote=242748:@Torsten Grube]???
I don’t know how to show a webpage. I tried some commands. But it doesn’t work. Is there any advice or examples?[/quote]

http://documentation.xojo.com/index.php/WebPage.Show

Thank you Michel, now I understand your question.

I’am searching for advice or example to use Javascript. A HTML-Viewer should contain a table. Each row in this table should contain a link. This link should contain a script to show a webpage or webdialog with detailed data.

[quote=242801:@Torsten Grube]Thank you Michel, now I understand your question.

I’am searching for advice or example to use Javascript. A HTML-Viewer should contain a table. Each row in this table should contain a link. This link should contain a script to show a webpage or webdialog with detailed data.[/quote]
Are you creating a Xojo web app? Or is this a general JavaScript question?

Forgive me for asking, but why go through such a convoluted way of displaying Xojo webpages, when a regular Xojo web control such as a PopupMenu or a series of buttons would be a whole lot easier ?

We use Xojo Webapp with all possibilties :wink:

Now we want to do following: A HTML-Viewer should contain a HTML-table. Each row in this table should contain a link. This link should contain a script to show a webpage or webdialog with detailed data.

Please see following example, each name should be a link and if the user clicks the link the app should show a dialogbox with detailed informations.


Will Smith Actor

Nicolas Cage Actor

Angela Merkel Chancellor

Is that possible? I think, we need Javascript for this. It would be nice to get any advice.

It would be easier to use a WebListBox for this than to hack a table together and mess around with javascript (which could interfere with the webapp itself)

This example shows you how to do a similar thing using a WebListBox instead: TableTest.xojo_binary_project

You did not answer Greg’s question, so I will suppose you will be displaying Xojo Webpages, and not HTML Web Pages.

With the normal Xojo links control, you can instead of an URL enter a hashtag, such as #WillSmithActor, so when the user clicks, it adds that to the URL bar. Such as http://127.0.0.1:8080/#WillSmithActor

That hashtag can be catched in the HashTagChanged event of Session. Then you can display the Webpage called WillSmithActor.

What you miss is that a WebHTMLViewer is an iframe, meaning links inside are not like the link control. When you click on a link inside a WebHTMLViewer, the URL is displayed inside that HTMLViewer, not in the main page. So the #Whatever would do nothing.

The alternative to the HTMLViewer is to use the WebSDK HTMLArea, which unlike an iFrame is fully part of the page HTML and allows setting the hashtag. See the HTMLArea example in Extras/WebSDK next to the Xojo executable.

Here is an example of what the Open event of the HTMLArea would contain :

Me.HTML = "<p>This is a <b>test</b></p><a href=#WillSmithActor>Will Smith Actor</a><br>"

You can replace that by a full table and all the links you want.

However, it falls on you to create all the corresponding Xojo webpages and manage the code in HashTagChanged to display them with show.

[quote=242745:@Torsten Grube]It is possible to start a method in the current webpage or session with javascript?
[/quote]

The answer is yes. The best way is to use the WebSDK controls and the JavaScript command Xojo.TriggerServerEvent. See WebSDK.pdf, in extras, next to the Xojo executable.

But if you want to trigger Javascript in an HTML table, you got to add some specific code in the HTML. See onclick Event

If you look for examples of using JavaScript in Xojo Web, type “executejavascript” in the forum search box, then click Web to have only the web threads. There are many posts.

Thank you all,

@Michael: I answered Gregg: We use Xojo Webapp with all possibilties.

I searched in the forum. But I didn’t found any example.
But now I know how to explain my question easier:

I would like to have a Javascript Formula that makes this.

Dim dlgA as dialogActor
Session.property1 = “1002”
dlgA.Show()

This formula should run, if the user click on the link in the table.

@Tim: Thank you for the example. We already use weblistboxes in the web application.

Is that possible to translate the formula above to Javascript?

I tried to give you an example of what can be done above, and JavaScript would not make it easier.

Thank you all for try to help.
I thought, it is possible to use Javascript to show a dialog or webpage of xojo (or to start a xojo method).
We need a html-table and with links to show the details of the row to edit data (like this forum). Ok, for this case we cannot use xojo.

[quote=243345:@Torsten Grube]Thank you all for try to help.
I thought, it is possible to use Javascript to show a dialog or webpage of xojo (or to start a xojo method).
We need a html-table and with links to show the details of the row to edit data (like this forum). Ok, for this case we cannot use xojo.[/quote]

This is getting annoying. We keep trying to help and you do not seem to understand anything. Or want to.

Torsten, forgive me, but you seem to have a slight attention deficit. Probably because you are obnubilated with displaying pages in JavaScript, you completely missed the fact that you can indeed do what you want WITHOUT Javascript, but WITH a little bit of efforts wrapping your head around the way Xojo Web works.

I tried to point you in the right direction in a detailed post above, and Tim provided a working example.

In HTML, absolutely no need for JavaScript to display a page. Neither in Xojo Web. Simply load your table in an HTMLArea, and make your links to hashtags. Do you know how to do that ?

[code]

Will Smith Actor
Nicolas Cage Actor

[/code]

When you click on a link, it changes the app Hashtag, which you catch in the Session HastagChanged, and that is where you will be displaying your dialogs and webpages.

NOW, since you seem obsessional about using JavaScript, here is the code for a cell content using JavaScript :

<a onclick="window.location.replace('#WillSmithActor')"> Will Smith Actor </a>

There. Now you need to LEARN how to use Xojo Web and simply TRY to wrap your head around these simple concepts.

Since you seem to have defined your app like an HTML site, it would be a whole lot simpler to create a static site doing exactly what you describe. Of course that would be hell maintaining, but that is besides the point. You seem to completely miss the intrinsic qualities of Xojo Web, since you have already decided to use an antiquated HTML table, instead of the Xojo controls and a powerful database.

All the javascript in the world cannot change a bad design.

May I suggest you have a look at the Eddies Electronics demo from Xojo to see what a good Web app looks like at
http://demos.xojo.com/EEWeb/#10012

Hello Michel,

We developed applications in the same complexity and more like Eddis Electronics demo. Now we want add to an application a list based on HTML. This may old fashioned for you, but not for us and shouldn’t be your problem.

With the example with hashtag you helped me really. Yes the hashtag is new for me. But I never heard about HTML Area and I searched for documentation WebSDK, you named above, in the ressources of Xojo, Please can you post a link to this? This will be very helpful for me (please without allegations). May be that I will find the needed information to get the functionality we need.

Thank you in advance

You are right. It actually is not my problem. Good luck.

There isn’t very much documentation HTMLArea from what I can find.

There’s some mentions in the WebSDK pdf, and there’s an example project:

[Xojo Folder]/Extras/WebSDK/Examples/HTMLArea.xojo_binary_project

It basically renders as a div with whatever html you put inside it.

Thank you all for your help. I found the example with HTMLArea and testet it. This will work fine for our requirements (HTML-Area + Hashtags).