detect | R Documentation |
This function must be called somewhere in a Shiny app's UI in order to use any other {shinybrowser} functions.
detect()
HTML dependencies that are required to use shinybrowser.
It's important to understand there is no reliable way to detect the
information in {shinybrowser} with 100% accuracy.
{shinybrowser} makes
a best effort at identifying the most accurate information, but some
browser/operating system combinations may be difficult to identify. Users
can also use a variety of tools to deliberately spoof this information.
With that in mind, {shinybrowser} should detect the correct information in
most cases.
Only major browsers and operating systems are supported, which means that the
RStudio Viewer may result in an "UNKNOWN" browser, and unpopular operating systems
may also result in "UNKNOWN".
For a list of values that can be detected, see SUPPORTED_BROWSERS,
SUPPORTED_DEVICES, and SUPPORTED_OPERATING_SYSTEMS.
{shinybrowser} attempts to detect whether a device is "mobile" or "desktop".
The distinction between mobile and desktop is not always clear, so if what you
actually care about is the size of the device, it might be better to use
get_width()
.
Tablets return ambiguous results; some tablets self-report as mobile devices while
others as desktop.
The width and height of the browser window are only reported once, when the detect()
function is initially called.
If the user resizes the browser window, the new dimensions are not reported until
the page is refreshed.
get_all_info()
, get_browser()
, get_os()
, get_device()
, get_width()
if (interactive()) {
library(shiny)
ui <- fluidPage(
shinybrowser::detect(),
"Your browser information:",
verbatimTextOutput("browser_info")
)
server <- function(input, output, session) {
output$browser_info <- renderPrint({
shinybrowser::get_all_info()
})
}
shinyApp(ui, server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.