Navigate: background tab on ctrl-click & mousewheel click

Hi Forum,

I'd like to create a script to open a page in a background tab.
Example: we have a dashboard of multiple machines and want to check details of 4-5 of them
At the moment we have to click a machine, navigate back, click the next, or copy the URL.

I have a (very simple) working test script that checks the ctrl-key state or if mousewheel click was used.

if event.ctrlKey:
	system.perspective.navigate(page,newTab=True)
elif event.buttons == 4:
	system.perspective.navigate(page,newTab=True)
else:
	system.perspective.navigate(page,newTab=False)

Now my issue is I want the new tab to be opened in the background so it is easy to open multiple pages from an overview.

I can't seem to find a setting for this in the documentation, is it possible?

I suspect that the behaviour is controlled by the browser, not by Ignition.

Firefox settings includes the option, "When you open a link, image or media in a new tab, switch to it immediately." I suspect that disabling this would give the behaviour you want.

Chrome doesn't seem to have it but browser extensions such as this one might do the job.

In both of those options the behaviour is under user control so you might be fighting a losing battle.

That would be very annoying....

I kind of hoped I could recreate the default ctrl-click behaviour.
Getting these settings configured or an additional extension on every browser is going to be impossible.

Browsers deliberately prevent this kind of behavior outside of direct user interaction, because browsers must be defensive.

There's no way for them to distinguish between "a trusted SCADA system" and "a random malicious site", and so if one is abusing the capability, all of them must be prevented from doing so.

Ceding control to browser vendors in this way is one of the most fundamental tradeoffs of Perspective.

Perspective workstation exposes some top-level configuration options that may give you the behavior you want.

2 Likes

I do wonder on a technical level how a browser distinguishes a scada web page from a 'regular' webpage.

I'd kind of assume something like ctrl-click works by default

It doesn't. That's the point. You can't do what you want with a script because Ignition's Perspective scripts run in the gateway, and browsers don't let webservers do anything they want. That would let webservers deliver malware. The user has to do it, not your script in the gateway.

It's a browser setting. Any default browser setting will vary between browser brands and can be overridden by the user.

A ctrl + click initiated by a user is treated separately by the browser, because the browser knows it's a "real" click, because it's a true native executable and got that information from the operating system. When you run something like system.perspective.navigate, you're running code on the gateway that ultimately sends a message down to the running browser page. There, Javascript, the only language that runs in web browsers natively and has access to the DOM, ultimately executes some kind of code that then hooks back into the web browser's native code; specifically something like Window.open on the global Window object. The browser knows that it's different, because no matter what you do, it can distinguish between "this is a native call that originated from the user's actual action" and "this is an action originating from a script". Even if you programmatically "click" a browser button, it will not have the same behavior as the user clicking that button.

The reason for this is the endless escalating arms race with malware vendors/distributors. Nothing for us to do, beyond providing our own "wrapped" browser engine with some defaults set automatically (see Perspective Workstation, linked above).

4 Likes