5

I'm running a standalone R Shiny app on Windows in a browser by setting options(browser=path/to/browser/exe) and using shiny::runApp("path/to/app", launch.browser=TRUE). The browser to support is MSIE (default), but, if available, it can be also be Chrome or Firefox. My goal is to run the app as if using the --app= command line option for a standalone Chrome app, i.e. in a new browser window, which is stripped of the menubar and the toolbar, but preserves the titlebar (so not in the "kiosk" mode), and, if possible, without any other contents of the browser (like previously opened tabs or a home page). What's the best way to do that?

For instance, using JavaScript, one would call:

window.open("http://127.0.0.1:5555/", "MyApp", "menubar=no,toolbar=no,location=no");

which would do the job (+/- inconsistent support for location=no, i.e. disabling the address bar, which I can live with). Now, how to do it using R Shiny?

trybik
  • 482
  • 6
  • 16
  • Possible duplicate of [Opening Shiny App directly in the default browser](https://stackoverflow.com/questions/35311318/opening-shiny-app-directly-in-the-default-browser) – Pork Chop Sep 12 '17 at 15:15
  • @pork-chop, nope, different Q there (more basic) – trybik Sep 12 '17 at 15:23
  • Do you need it to support all browsers or is just IE enough? – sebastian-c Sep 20 '17 at 16:32
  • I don't need to but I would like to support all browsers such that the solution applies also on OS X – trybik Sep 21 '17 at 11:00
  • 1
    I think the *kiosk* style settings are rather browser dependant. The answer by AEF does seem to address your requirements. I would only add that the RStudio IDE offers an API that may be useful to meet what you want cross-platform, `runApp("path/to/app", launch.browser = rstudioapi::viewer)`. – Kevin Arseneau Sep 23 '17 at 02:19
  • Correct, but "kiosk" also does not meet my requirements because it lacks titlebar, and correct AEF answer is a workaround for IE (additionally to Chrome "apps" support). I've also considered `rstudioapi::viewer` before posting, but that only works if there is R Studio installed, doesn't it? If so, unless I could get the viewer separately, preferably as a R package, this would be a solution in line with shipping with Chrome installer (except maybe that Chrome will drop support for "apps" in the near future). – trybik Sep 25 '17 at 06:21
  • Addendum: for `rstudioapi::viewer`, R Studio has to be not only installed but also actually running. – trybik Sep 25 '17 at 06:33

1 Answers1

6

It's not very elegant, but you can start Internet Explorer by the COM interface using e.g. package RDCOMClient.

As the documentation states, the launch.browser argument can also be a function which is given the URL of the app, so we can create the object there:

library(RDCOMClient)

runApp("path/to/app",
       launch.browser = function(shinyurl) {

         ieapp <- COMCreate("InternetExplorer.Application")
         ieapp[["MenuBar"]] = FALSE
         ieapp[["StatusBar"]] = FALSE
         ieapp[["ToolBar"]] = FALSE
         ieapp[["Visible"]] = TRUE
         ieapp$Navigate(shinyurl)

        })
AEF
  • 5,408
  • 1
  • 16
  • 30
  • That works with IE indeed like intended - nice. I'm still fishing for a browser-independent workaround. (I can't imagine anything else here except JS window.open/window.close shenanigans.) – trybik Sep 22 '17 at 09:13