Wepage.show(True) How To open a webPage in a new Window

Hi guys!
I need to open a webPage in a new window with this code:

//WP is a valid WePage
Dim InNewWindow As Boolean = True
WP.Show(InNewWindow)

This error.Code apear:
This Method requieres fewer parameters than were passed

Some idea?
Thank you a lot!

Relevant note from WebPage.Show:

I guess I should update the method signature for that page!

Anyway, you cannot open a new window (or tab) from code. A new window can be opened by a user clicking on a WebLabel by setting the Target property to “New Window”.

In a button :

Sub Action() ExecuteJavaScript("window.open(""http://www.w3schools.com"");") End Sub

[quote=157254:@Michel Bujardet]In a button :
Sub Action()
ExecuteJavaScript(“window.open(”“http://www.w3schools.com”");")
End Sub
[/quote]
Keep in mind that this will only work if the user has not popup blocker on their browser. Otherwise, opening a new window requires the code being executed in direct response to a user clicking a button or a link (in the same event loop).

Ok, thank you so much!

But is it still possible to show a Xojo WebPage in a new window/tab ?

Sure. In the example I posted above, just put the URL of your app. To show a particular page, use an URLParameter and check in Session.Open which page should be displayed.

For instance

ExecuteJavaScript("window.open(""http://127.0.0.1:8080/?page=WebPage11"");")

You do not need JavaScript if you use a Link and set the target to ‘New Window’.

Note that the page displayed in the new window, or tab if there were already other tabs open, will start a new session. So if you want the new page to communicate with the previous one, you will have to do some extra work.

Thanks @Michel Bujardet !
But, as you said, it’s a another session and the authentification has to be done again…
I was searching for a new window using the same session, but this is probably impossible :frowning:

[quote=213778:@ValryTarondeau]Thanks @MichelBujardet !
But, as you said, it’s a another session and the authentification has to be done again…
I was searching for a new window using the same session, but this is probably impossible :([/quote]

No, it is not possible to go to the same session. But as I showed you, you can bypass authentication and go directly to a page. If you want to make sure the new page is authorized, you may use another parameter to carry an encrypted token that will allow you in the newly opened page that it really comes from the original app.

Check the PushExample in Web for a way to communicate between sessions.

OK, thanks for your quick and precise answers !

You’re welcome :slight_smile:

If you want to keep the same session, but create a new Windows then use a palette dialog window instead.

That won’t work for a new browser window or tab.

Michel - awesome as always.