-1

I need to embed a webpage reached through a url inputted by the user. I found this script but I can't make the iframe depend on a textInput() containing a url.

embed iframe inside shiny app

Thank you

Claudio Paladini
  • 562
  • 1
  • 9
  • 17

1 Answers1

1

You can do like this:

library(shiny)
ui <- fluidPage(titlePanel("Getting Iframe"), 
                sidebarLayout(
                  sidebarPanel(
                    textInput("url", label = "Enter url"), 
                    actionButton("go", "Go")
                  ),
                  mainPanel(
                    htmlOutput("frame")
                  )
                ))

server <- function(input, output) {
  output$frame <- renderUI({
    validate(need(input$go, message=FALSE))
    tags$iframe(src=isolate(input$url), height=600, width=535)
  })
}

shinyApp(ui, server)
Stéphane Laurent
  • 59,551
  • 14
  • 99
  • 196