runjs | R Documentation |
Run arbitrary JavaScript code.
runjs(code)
code |
JavaScript code to run. |
shinyjs
must be initialized with a call to useShinyjs()
in the app's ui.
useShinyjs
if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
useShinyjs(), # Set up shinyjs
actionButton("btn", "Click me")
),
server = function(input, output) {
observeEvent(input$btn, {
# Run JS code that simply shows a message
runjs("var today = new Date(); alert(today);")
})
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.