Redirect in Shiny app

前端 未结 1 1744
悲哀的现实
悲哀的现实 2021-02-14 01:26

I\'m trying to make my Shiny app to redirect the user to another page. I\'m using httr to send GET requests and see if the user is logged in. If he\'s

1条回答
  •  隐瞒了意图╮
    2021-02-14 02:01

    Here this will navigate you to google if not true

    library(shiny)
    
    jscode <- "Shiny.addCustomMessageHandler('mymessage', function(message) {window.location = 'http://www.google.com';});"
    
    ui <- fluidPage(
      tags$head(tags$script(jscode)),     
      checkboxInput("Redirect","Redirect",value = T)
    )
    
    server <- function(input, output, session) {
    
      observeEvent(input$Redirect,{
        if(!input$Redirect){
          session$sendCustomMessage("mymessage", "mymessage")
        }
      })
    }
    
    shinyApp(ui,server)
    

    0 讨论(0)
提交回复
热议问题