R Shiny: launching a standalone browser window when runApp is called

I launch the standalone R Shiny application for Windows in a browser by setting options(browser=path/to/browser/exe ) and using shiny::runApp("path/to/app", launch.browser=TRUE) . The support browser is MSIE (by default), but if available, it can also be Chrome or Firefox. My goal is to launch the application as if the command line option --app= for a standalone Chrome application, that is, in a new browser window, which is deprived of the menu bar and toolbar but retains the title (so it’s not in the β€œkiosk”) , if possible, without any other browser content (for example, previously opened tabs or the home page). What is the best way to do this?

For example, using JavaScript, you could 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 with which I can live). Now how to do it using R Shiny?

+5
source share
1 answer

This is not very elegant, but you can start Internet Explorer through the COM interface using, for example, the RDCOMClient package.

As stated in the documentation, the launch.browser argument launch.browser also be a function that launch.browser application URL, so we can create an 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) }) 
+6
source

Source: https://habr.com/ru/post/1271734/


All Articles