[SOLVED] Open link in new tab

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

Locked
User avatar
noyzen
Posts: 16
Joined: Fri Jan 01, 2010 2:07 am

[SOLVED] Open link in new tab

Post by noyzen »

Hi,
there is a button, and a "link/href" property.
i have a variable like [the_url] and when i put it there it works and when user click button he will go to that link.

now i want open that link in new tab, i spend almost whole day but cant make it...
anyone know how to do it?

Thanks :lol:
Last edited by noyzen on Fri Mar 30, 2018 9:20 am, edited 1 time in total.
old Neobook user, and now Neo AppBuilder.
i'm Graphic Designer and a Non-Programmer! :)
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Open link in new tab

Post by Gaev »

noyzen:

1) Leave the link/href property of the Button empty.

2) Place these commands in the Code section (tab) for the Button ...

Code: Select all

BeginJS
window.open('https://www.google.com','_blank');
EndJS
... just replace https://www.google.com with the URL of your target webpage.
User avatar
noyzen
Posts: 16
Joined: Fri Jan 01, 2010 2:07 am

Re: Open link in new tab

Post by noyzen »

Thank you, it works.
but i cant change url with variable...

BeginJS
window.open([ad_url],'_blank');
EndJS

and

BeginJS
window.open('[ad_url]','_blank');
EndJS

both fail :oops:
old Neobook user, and now Neo AppBuilder.
i'm Graphic Designer and a Non-Programmer! :)
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Open link in new tab

Post by Gaev »

noyzen:
but i cant change url with variable...
That is because you can not use regular NeoAppBuilder variables (i.e. those wrapped within [ and ] ) with javascript commands (i.e. commands used between BejinJS and EndJS ... you have to copy values from one namespace to another ... this is done using $rootspace like in the example below ...

Code: Select all

SetVar [neoVarURL] "https://www.google.com"

BeginJS
jsVarURL= $rootScope.neoVarURL;
window.open(jsVarURL,'_blank');
EndJS
Of course you can set [neoVarURL] anywhere else in your App; just make sure it is setup as a global (not local) variable.

To learn more about variables, read the Help file ... and search the General NeoAppBuilder Discussion Forum.
User avatar
noyzen
Posts: 16
Joined: Fri Jan 01, 2010 2:07 am

Re: [SOLVED] Open link in new tab

Post by noyzen »

Thank you very much, it works great!
i mark this topic as solved so it may help other people too.
Regards,
old Neobook user, and now Neo AppBuilder.
i'm Graphic Designer and a Non-Programmer! :)
Locked