Embedding an HTML document using `tags$iframe()` on the full page height

I'd like to embed a local HTML document in a Shiny app (I used an URL here for the purpose of the example).

includeHTML() works well but I'm getting a message suggesting to use tags$iframe() instead. The problem is that iframe() seems to use a fixed height for the embedded document, which isn't convenient. Is there any way to use the full height of the page with iframe()? Using height = "100%" doesn't work obviously and the function doesn't seem to have a minHeight parameter.

library(shiny)
  
ui <- fluidPage(
  htmlOutput("html")
)

server <- function(input, output, session) {
  output$html <- renderUI({
    # includeHTML("https://www.york.ac.uk/teaching/cws/wws/webpage1.html")
    tags$iframe(
      srcdoc = readr::read_file("https://www.york.ac.uk/teaching/cws/wws/webpage1.html"),
      width = "100%",
      frameBorder = "0",
    )
  })
}

shinyApp(ui, server)

How about this where height is set as 100 % of the viewport height using the css 100vh? I changed the URL since the one you were using forbid embedding in an iframe and there's no need to use renderUI unless the content will be rendered dynamically.

library(shiny)

ui <- fluidPage(
  tags$iframe(
    src = "https://www.sheldonbrown.com/web_sample1.html",
    width = "100%",
    style = "height: 100vh",
    frameBorder = "0"
  )
)

server <- function(input, output, session) {

}

shinyApp(ui, server)
1 Like

Interesting, I tried height = "100vh" before and it didn't work. Not sure why we've to use style instead.

Thanks anyway, that works great!