Hi,
I need to open a New Browser Tab. I like to use a javascript function that I found here on xojo forum:
function open_in_new_tab(url )
{
var win=window.open(url, '_blank');
win.focus();
}
Where and how I can call from xojo this javascript function?
If you have a browser with locked popups this code will fail.
You should use: (put in the web app header)
function openInNewTab(url) {
var win=window.open(url, '_blank')
if (win) {
win.focus
} else {
alert("Enable popups")
}
}
You could use a link object on the page (it works in any case) and by code set the visibility, the url and the text
You could use a webStyle (and extra information for style in the webApp header) to let the link object appear as a button
OK Antonio, thank you for quick response.
I tried with a link with a weblabel and I set the target to ‘New Window’: http://127.0.0.1:8080/?page=spec_day_WP
but in the new window it not open spec_day_WP but the startup page.
So I tried with a button and in the action event I wrote:
ExecuteJavaScript(“window.open(”“http://127.0.0.1:8080/?page=spec_day_WP”");")
Same problem!
Where I fail?
Thank you
Do you read the page parameter in session.open ?
You could use the tag (/#spec_day_wp) to handle this (both, if needed, in open and HashTagChanged)
There is no need to call JS, you could also use session.showUrl to create new web Page/Tab (but as your JS if can fail if pop up are blocked) the link will work always.
IN ANY CASE THE NEW WINDOW WILL BE A NEW SESSION NOT A NEW WINDOW ON THE SAME SESSION
Just a detail. When you post code, make sure to select it and click the code icon above the editor . It makes it way more legible.
ExecuteJavaScript("window.open(""http://127.0.0.1:8080/?page=spec_day_WP"");")
What kind of code are you using to parse the page parameter and display the corresponding page ?