# Open link in browser via scripting

**URL:** <https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034>\
**Category:** Ignition\
**Created:** [June 19, 2020, 1:10pm UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034 "2020-06-19T13:10:28Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![iscrac](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/iscrac/32/49757_2.png) [@iscrac](https://forum.inductiveautomation.com/u/iscrac)\
**Post date:** [June 19, 2020, 1:10pm UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/1 "2020-06-19T13:10:28Z")

</div>

hey!  
I did the navigation the other way:  
I don’t use Vision Menu Tree. Now I use Perspective Menu Tree, so now it works without any Gateway scripts.

But now I have the other problem: I cant open url in new tab via script system.perspective.navigate(url=‘link’)…  
I searched for the information about it on the forum and I found that it’s impossible 🤣

I need to open new link in new window, because IFrame can’t show me GoogleMap 🥴

I am lost… 🥺

---

<div class="post-metadata">

**Author:** ![KGarner](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgarner/32/15999_2.png) [@KGarner](https://forum.inductiveautomation.com/u/KGarner)\
**Post date:** [June 22, 2020, 1:35pm UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/2 "2020-06-22T13:35:32Z")

</div>

I think you might be looking for the [webbrowser](https://www.jython.org/jython-old-sites/docs/library/webbrowser.html) jython module that should be included in Ignition’s install.

```auto
import webbrowser
webbrowser.open_new_tab('https://google.com')

```

---

<div class="post-metadata">

**Author:** ![iscrac](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/iscrac/32/49757_2.png) [@iscrac](https://forum.inductiveautomation.com/u/iscrac)\
**Post date:** [June 25, 2020, 5:38am UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/3 "2020-06-25T05:38:28Z")

</div>

> [@KGarner](#):
>
> I think you might be looking for the [webbrowser](https://www.jython.org/jython-old-sites/docs/library/webbrowser.html) jython module that should be included in Ignition’s install.

Thanx!!  
But it does not open(

> Error running action 'component.onItemClicked' on MAP\_Vision (1)@C/root/Content/MENU/MenuTree: Traceback (most recent call last): File "function:runAction", line 39, in runAction File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\webbrowser.py", line 26, in open\_new return self.open(url, 1) File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\webbrowser.py", line 23, in open raise Error(e) webbrowser.Error: java.io.IOException: Failed to open [Google Maps](http://www.google.com/maps/place/59.464582,24.994132). Error message: An error occurred in sending the command to the application.

---

<div class="post-metadata">

**Author:** ![KGarner](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgarner/32/15999_2.png) [@KGarner](https://forum.inductiveautomation.com/u/KGarner)\
**Post date:** [June 25, 2020, 1:07pm UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/4 "2020-06-25T13:07:47Z")

</div>

Without knowing the specifics of your system, I think it might have something to do with [this](https://support.mozilla.org/en-US/questions/760489).

You can use the webbrowser module to open your preferred browser and then open the URL after.

Ex:

```auto
import webbrowser

url = 'http://docs.python.org/'

# MacOS
chrome_path = 'open -a /Applications/Google\ Chrome.app %s'

# Windows
# chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'

# Linux
# chrome_path = '/usr/bin/google-chrome %s'

webbrowser.get(chrome_path).open(url)

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 25, 2020, 2:43pm UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/5 "2020-06-25T14:43:16Z")

</div>

Another option:

```auto
from com.inductiveautomation.ignition.client.util import BrowserLauncher
BrowserLauncher.openURL("https://google.com")

```

Another option, depending on your platform, is `system.util.execute` - Windows has a `start` executable that will open a link with the associated default program, and on most Linux desktops you could use `xdgopen`.

---

<div class="post-metadata">

**Author:** ![iscrac](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/iscrac/32/49757_2.png) [@iscrac](https://forum.inductiveautomation.com/u/iscrac)\
**Post date:** [June 26, 2020, 7:36am UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/6 "2020-06-26T07:36:38Z")

</div>

thanx guys! 💥  
but nothing’s working for me… Unfortunately…

actually it’s strange why system.perspective.navigate doesn’t have the function NewTab…  
I think it’s very important to have this!  
Hope the function will be presented in the future…

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [June 26, 2020, 11:13am UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/7 "2020-06-26T11:13:44Z")

</div>

> [@iscrac](#):
>
> actually it’s strange why system.perspective.navigate...

All the examples given were examples for Vision, not perspective. Perspective scripts run on the gateway, so you can't launch other applications there.

In HTML, it would be as simple as [adding a target to a link](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target), but I don't know perspective well enough to know how you should achieve this in perspective.

---

<div class="post-metadata">

**Author:** ![KGarner](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgarner/32/15999_2.png) [@KGarner](https://forum.inductiveautomation.com/u/KGarner)\
**Post date:** [June 26, 2020, 1:49pm UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/8 "2020-06-26T13:49:43Z")

</div>

@Sanderd17 ‘s response made me take a step back and re-read the original post. I apologize for potentially leading you down the wrong path.

If you are using the Perspective Menu Tree, there is a “target” property in each of your items. You may place an external url there and it _ **should** _ open in a new tab

Otherwise, you might look into placing the [Link Component](https://docs.inductiveautomation.com/display/DOC80/Perspective+-+Link) on a page for navigation.

I would be interested in knowing whether this solves your problem or if you still need some way to do this via scripting.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![iscrac](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/iscrac/32/49757_2.png) [@iscrac](https://forum.inductiveautomation.com/u/iscrac)\
**Post date:** [June 29, 2020, 5:34am UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/9 "2020-06-29T05:34:00Z")

</div>

> [@KGarner](#):
>
> Hope this helps!

Hey,  
the easiest solution I have ever met 😄  
Thanx so much!! It works of course! 👌 🤝

---

<div class="post-metadata">

**Author:** ![iscrac](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/iscrac/32/49757_2.png) [@iscrac](https://forum.inductiveautomation.com/u/iscrac)\
**Post date:** [June 29, 2020, 11:33am UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/10 "2020-06-29T11:33:33Z")

</div>

hey,

Can You give me one advise about how to check if I pressed “BACK” in menu tree?  
I thought I can get a path for that with value “0”, but it gives no path if I press “BACK”…  
so… how to know if I pressed back?

---

<div class="post-metadata">

**Author:** ![iscrac](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/iscrac/32/49757_2.png) [@iscrac](https://forum.inductiveautomation.com/u/iscrac)\
**Post date:** [June 30, 2020, 8:01am UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/11 "2020-06-30T08:01:04Z")

</div>

> [@iscrac](#):
>
> how to know if I pressed back?

I solved my issue!)  
No need for help anymore! Thanx everyone who tried to help me! 💥

---

<div class="post-metadata">

**Author:** ![Carlos\_Torrez](https://avatars.discourse-cdn.com/v4/letter/c/a587f6/32.png) [@Carlos\_Torrez](https://forum.inductiveautomation.com/u/Carlos_Torrez)\
**Post date:** [May 11, 2024, 9:12pm UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/12 "2024-05-11T21:12:40Z")

</div>

A mí me sirvió para Visión, excelente aporte. Mi consulta como puedo agregar a cada fila de una tabla un link para ejecutar este script?

Tengo una tabla con una lista de temas, la idea es dar click y que abra el archivo PDF del tema correspondiente.

Agradecido de antemano

Carlos T

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 11, 2024, 9:23pm UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/13 "2024-05-11T21:23:47Z")

</div>

Hi, Carlos.  
Please post in English as well. Use Google Translate or something else. Click the pencil icon to edit your post.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 11, 2024, 11:22pm UTC](https://forum.inductiveautomation.com/t/open-link-in-browser-via-scripting/36034/14 "2024-05-11T23:22:13Z")

</div>

You may also want to start a new topic: hoping for an answer on a four-year-old topic from some who hasn't event visited the forum in almost that long is probably unrealistic.
