Hi there,
I was wondering if there was a way to determine what browser e.g. Chrome/Safari/Firefox, your Shiny app is running in?
I ask because I'm using https://github.com/rowanwins/leaflet-easyPrint but it only supports Chrome + Firefox. I'd like to disable/hide the ui element related to the plugin if the browser isn't supported.
Many thanks,
Ciaran
I think it's not available directly via shiny, but you need to add some javascript for it. A very basic solution could look like below. Notice: this check is not perfect since a user might manually change the useragent name.
check.js
$(document).on('shiny:sessioninitialized', function(event) {
var isChrome = /Chrome/.test(navigator.userAgent);
var isFirefox = /Firefox/.test(navigator.userAgent);
var message = {data : [isChrome, isFirefox] };
Shiny.onInputChange("check", message);
});
app.R
library(shiny)
ui <-shinyUI(
bootstrapPage(
includeScript("www/check.js"),
textOutput("text")
)
)
server <- shinyServer(function(input,output,session){
output$text <- renderText({
paste("Chrome, Firefox:", input$check)
})
})
shinyApp(ui = ui, server = server)