New Web Browser Tab

Use this board to ask questions or have discussions with other Rich Displays users.
rmullis99
Profound User
Posts: 26
Joined: Wed Jun 24, 2015 9:33 am
First Name: Robert
Last Name: Mullis
Company Name: UFCW
Contact:

Re: New Web Browser Tab

Post by rmullis99 »

Hi Scott,

I was finally able to get this to work, but I have one last issue. I have a menu widget loaded with the options that I want to open in a new tab. In the menu's onclick event I use pui.click() to have my program set a textbox with the URL to open in the new tab. I would like the new tab to automatically open when the URL is set. I have tried several variations, but so ar haven't been able to get it to work.

Any suggestions?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: New Web Browser Tab

Post by Scott Klement »

Robert, this would be a lot more elegant if you didn't go back to the RPG program. But, even if you do go back to RPG, I can't see why you'd use the onclick event or pui.click(), here.

My first choice would be to use the 'onoptionclick' event on your menu. This will give the menu option that was selected, etc, to a JavaScript routine. This is the best way to react to the user clicking a menu option. I'm hoping that you can use this to build the URL in JavaScript so you don't need to go back to the RPG program, since this would be a lot nicer. If necessary, you can put additional information in the menu's "choice values" to give you the info needed for the URL.

If you can build the URL in the onoptionclick routine, then you can simply run the window.open() from there. That would be much more elegant than going back to the RPG.

If you do need to go back to the RPG (because you need something from the RPG, such as to update a database or whatever) then I would use 'menu response' and not onclick or pui.click(). 'menu response' will send the menu option back to RPG without any JavaScript coding. Then, you'll need to have logic in your screen's "onload" event that looks for the textbox with the URL to be filled in... the logic would be something like if it has a URL in it, call window.open(), and then clear out the textbox. When the textbox is empty, of course, you would not open a new window.

Again, I would only do that if you absolutely cannot use onoptionclick to avoid going back to RPG. The onload logic would look something like this (it's off the top of my head, untested):

Code: Select all

var winURL = pui.get("TheTextBoxId");
if (winURL != "") {
   window.open(winURL);
   pui.set("TheTextBoxId", "");
}
Your RPG code would, of course, need to be careful to leave the textbox blank unless it wanted to open a new window.
rmullis99
Profound User
Posts: 26
Joined: Wed Jun 24, 2015 9:33 am
First Name: Robert
Last Name: Mullis
Company Name: UFCW
Contact:

Re: New Web Browser Tab

Post by rmullis99 »

Thanks Scott.

I got the "onload" to work. I used it, because I have to return to my RPG first to do other stuff besides setting the URL.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest