New Window instead of new tab

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
So I have a formula URL that has the option ticked for "open in new window"...and this does sort of work---it's a limitation of my BROWSER settings that it chooses new windows to open in new TABS. And while that is normally the behavior I prefer (in general), I would like to make my "click to track" button actually open in a new window regardless of my browser settings.
I assume this is a javascript thing, but since I don't KNOW javascript, I'm hoping one of you out there in Qbase land smarter than I can help me?
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Hi Stephen, I've done this a few times, usually in formula text fields. The basic idea is that you need a little bit of javascript ahead of the url, something like: onclick=\"var a=window.open('"&[url goes here], 'newwindow', 'width=600,height=200');

Where the width and height control the size of the window, however you can probably remove that or add a full size modifier. 

If you need assistance making this work, feel free to reach out to me via the info in my profile and my team can help you further. 

Good luck! 
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
onclick=\"var a=window.open('"&[url goes here], 'newwindow', 'width=600,height=200'); 
Gives a warning that it needs a parenthesis after onclick..I was using a formula URL (not formula text) so I just must have my syntax wrong?
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
I think Eric was providing you with an example to show you the proof of concept.

You will need it to be a formula-text field and the portion that contains the action when clicked will be:

"<a class='Vibrant Success' onclick=\"var a=window.open('https://www.google.com/', 'newwindow', 'width=600,height=600');\" >Google</a>"

This one is tested and works.
Photo of Stephen

Stephen

  • 760 Points 500 badge 2x thumb
Matthew, (and Eric) yes, thanks! I'm completely uneducated on Javascript and even when I look things up on the 'net I find that I'm struggling with syntax. Thank you for helping me apply what eric did to the field. Is there some sort of resource regarding syntax for basic stuff like this you might suggest to help newer-users like me who have some programming knowledge (enough to be dangerous) but are unfamiliar with syntax and other applications of the details? 
I am doing some online javascript tutorials to learn the basics but still hope to find a reference on how to apply them specifically to quickbase.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,242 Points 20k badge 2x thumb
There are 100 of script examples in this application that were created in answer to questions or as part of a demo:

Pastie Database
https://haversineconsulting.quickbase...

Most of the scripts have placeholders or parameters for dbid's and application tokens while fids and other data are typically hardcoded in the script. Generally you can modify these variables to match you values and keep the rest of the script unchanged. To get script to work in QuickBase you have to do some advanced things (like place all your code within a closure) but luckily the advanced parts are boilerplate that does not need to be changed. I would encourage you to learn JavaScript but I would work from an existing script as there are some best practices used to make the script work well within QuickBase.
(Edited)