# PlotlyJS: Select Browser to display html output

**URL:** https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277
**Category:** General Usage
**Tags:** plotlyjs
**Created:** [March 18, 2023, 11:13am UTC](https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277 "2023-03-18T11:13:56Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [March 18, 2023, 11:13am UTC](https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277/1 "2023-03-18T11:13:56Z")

</div>

I have tried to find advise, how to specify the browser that is used to display the interactive html-ouput from `PlotlyJS`:  
I found some discussion how to change the default browser, but I would not like to change the the default browser but I would like to specify the browser which opens the `PlotlyJS` output. Therefore, the discussion here does not seem to be the right method:

> [@How to change default browser of Jupiter notebook in IJulia?](https://discourse.julialang.org/t/how-to-change-default-browser-of-jupiter-notebook-in-ijulia/94790):
>
> In these two links, [https://stackoverflow.com/questions/47772157/how-to-change-the-default-browser-used-by-jupyter-notebook-in-windows](https://stackoverflow.com/questions/47772157/how-to-change-the-default-browser-used-by-jupyter-notebook-in-windows), [https://stackoverflow.com/questions/35229604/how-to-change-the-default-browser-used-by-the-ipython-jupyter-notebook-in-linux?rq=1](https://stackoverflow.com/questions/35229604/how-to-change-the-default-browser-used-by-the-ipython-jupyter-notebook-in-linux?rq=1), we can change default browser of ipython/jupyter notebook. But how to do this in IJulia?

On Windows my preference to display the `PlotlyJS` output is the browser `edge`, the strange thing is, this was not my system wide default browser, but it was the one who was selected to display the `PlotlyJS` output, unfortunately, this setting has changed (probably due to a package update) now I wonder, if I can change back to the previous setting.

---

<div class="post-metadata">

### Author: ![J\_Braulio\_Ramz\_G](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_braulio_ramz_g/32/47609_2.png) [@J\_Braulio\_Ramz\_G](https://discourse.julialang.org/u/J_Braulio_Ramz_G)
#### Post date: [March 21, 2023, 5:44pm UTC](https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277/2 "2023-03-21T17:44:29Z")

</div>

Hello you can try somethig like this:

```julia
using PlotlyJS
# Define the thing you want to plot
f(x) = exp(-0.1*x^2)*cos(x)
p = plot(f,-10,10)

#save it as an .html file
savefig(p, "myplot.html")

# using run() to open the html file with an specified browser
# Open the saved plot file in Firefox browser

run(`"C:\\Program Files\\Mozilla Firefox\\firefox.exe" myplot.html`)

```

That should make the trick, but if you are using a different operating system or different browser, you need to modify the path of executable and run() (or analogue) sintax accordingly.

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [March 28, 2023, 9:45am UTC](https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277/3 "2023-03-28T09:45:33Z")

</div>

Thanks for the idea! - Another workaround is: you plot all the time in the same file and open this file with your preferred browser …  
Better would be, if I could specify the default browser for PlotlyJS-outputs …

---

<div class="post-metadata">

### Author: ![J\_Braulio\_Ramz\_G](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_braulio_ramz_g/32/47609_2.png) [@J\_Braulio\_Ramz\_G](https://discourse.julialang.org/u/J_Braulio_Ramz_G)
#### Post date: [March 28, 2023, 5:23pm UTC](https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277/5 "2023-03-28T17:23:30Z")

</div>

You are welcome!

I usually work with jupyterlab() notebooks from the IJulia package, so this allows to create folders and files for each project you are working on.

Usually, I plot with gr() from the Plots package or with PyPlot which are displayed inside the Jupyter notebooks. When plotting with PlotlyJS in Jupyterlab I have experienced some troubles related to the WebIO extension, so instead, I use that previous code to save the figure, but if the file is not strictly needed, I just copy the plot code in the Julia REPL and their default output works for me.

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [March 29, 2023, 1:10am UTC](https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277/6 "2023-03-29T01:10:48Z")

</div>

I don’t think this change was caused by Julia or a package update. The method `PlotlyJS` uses from `PlotlyBase` is to just open `.html` files directly with the Windows system, and your preference for this is set in Windows itself.

If you really want to ensure you will launch PlotlyJS plots, then you can overwrite the `PlotlyBase.launch_browser` method:

```julia
using PlotlyJS
import PlotlyJS: PlotlyBase.launch_browser
# The run command here is specific for Windows:
launch_browser(tmppath::String) = run(`cmd /c start msedge $tmppath`)

```

Then this launches in MS Edge:

```julia
julia> p = Plot(x -> cos(x),-10,10)

```

but notice that this has uppercase `Plot`.

If you use lowercase `plot` then the default is to use Blink and launch an Electron window:

```julia
julia> p = plot(x -> cos(x),-10,10)

```

If you want to by-pass `Blink` in this case, then you need to overwrite PlotlyJS’s `Base.display` method:

```julia
Base.display(::PlotlyJS.PlotlyJSDisplay, p::PlotlyJS.SyncPlot) = display(p.plot)

```

but of course, you lose the JavaScript callback functionality.

---

<div class="post-metadata">

### Author: ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)
#### Post date: [March 29, 2023, 2:14am UTC](https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277/7 "2023-03-29T02:14:20Z")

</div>

More of another potential workaround rather than a solution, but I have been using this browser selector for some time on my windows machine:

> **[Browser Tamer](https://www.aloneguid.uk/projects/bt/)**
>
> Super fast, tiny desktop Windows app that helps to redirect clicked links to a correct web browser.

You set this as default browser and then specify which browser to actually use for each url based on regular expressions

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [March 29, 2023, 6:56am UTC](https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277/8 "2023-03-29T06:56:07Z")

</div>

@jd-foster Thanks jd!  
I will add this to my `startup.jl` 🙂

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [March 29, 2023, 7:02am UTC](https://discourse.julialang.org/t/plotlyjs-select-browser-to-display-html-output/96277/9 "2023-03-29T07:02:48Z")

</div>

> [@disberd](#):
>
> ### [Browser Tamer](https://www.aloneguid.uk/projects/bt/)
> 
> […] specify which browser to actually use for each url based on regular expressions

Thanks for this proposal!
