Experience in stopping a popup bug when opening in new tab

Experience in stopping a popup bug when opening in new tab

  

I am having an issue where some of my users are opening links that are to popups in a new tab (not coded to do so).  Clearly this then causes errors when viewing and running close popup actions on that screen.

Is anyone aware of a way to either block an item being opened in a new tab where it is a popup or stop these issues from appearing on the new tab when this happens?

Dan

Hello Daniel, 

To make sure your end-users are not able to open the popup in a new tab or window you could use a new link that uses the Ajax Sumbit method.
This new link will call a server action that then runs a simple snippet of JavaScript to open your original Navigate link (to which your Popup editor widget is associated). 

Your new link will be the one visible to your users and your original link will be hidden using the extended properties to define a style of "display: none".

I included below a step by step example that hopefully will be helpful.

Example:

  1. Create a new link (that your end-users will click to open the popup) with the Ajax Submit method and set it's destination to a new user action (OpenPopup action in this example);
  2. Set the style of your original link to "display: none" using the extended properties;
  3. Add the reference to the RunJavaScript server action from HTTPRequestHandler in the Manage Dependencies window;
  4. The user action (OpenPopup action in this example) that is called when your end-users press the visible link should use the RunJavaScript server action with JavaScript that will open your original "hidden" link.
    Remember to replace the "HiddenOpenPopup.Id" with the Id of your original link  "$('#"+HiddenOpenPopup.Id+"').click();"

Hi,


An alternative could be (because I am not sure João's solution will work when  the user right-clicks) that 

you could use the way outsystems handles it with the internal-error page for example..

this way you know when the page is inside a popup or not.


SyntaxEditor Code Snippet

"<script type='text/javascript'>
 if (parent!=window){ //Is inside frame
  document.getElementById('" + lnkPopup.Id + "').style.display='';
  document.getElementById('" + lnkNormal.Id + "').style.display='none';
 } 
 else {
  document.getElementById('" + lnkPopup.Id + "').style.display='none';
  document.getElementById('" + lnkNormal.Id + "').style.display='';
 }
</script>"


J. I was curious about what would happen so I checked and this is how it looks like when the user right clicks the new button (in Chrome):

Pressing the middle mouse button does nothing;
Pressing Ctrl+left mouse button opens the Popup in the same window/tab.

A caveat is that if the end-user inspects the page's html he can find the hidden link and get the url for the popup which he can then open in a new tab.

True and you cannot stop the curious user doing stuff you don't want to :D


(find it weird though, i can always open a button or a link in a new tab, not tested your implementation though)


Hello guys :)

Just for the reference, the solution provided by João works because it is using a button widget that is translated by OutSystems as an INPUT. The browser does not interpret it the same way as links, thus it does not allow the "right click and open in new tab".

With a link this solution does not work, as the browser does not care what will happen when you click it, allowing the right click and open in new tab.

Cheers.

You are right Eduardo, it is indeed the use of the button widget that leads to that behavior (middle button and no "right click and open in new tab"). Thank you for this insight!

As Eduardo said using a link instead of a button will allow the end-user be able to see the open in new tab option (after right clicking) and clicking with the middle button will open a new tab. It is important to note that the new tab/window will not open the popup, it will open the same page again, the popup will only open if the user left clicks the link. Pressing the link with CTRL+ left mouse button will open the popup in the same tab/window.