I am trying show a iframe with a website in shiny, but it is always showing blank page.
Below is the code taken from a different question
Code:
rm(list = ls())
library(shiny)
members <- data.frame(name=c("Name 1", "Name 2"), nr=c('BCRA1','FITM2'))
ui <- fluidPage(titlePanel("Getting Iframe"),
mainPanel(fluidRow(
htmlOutput("my_test")
)
)
)
server <- function(input, output) {
output$my_test <- renderUI({
tags$iframe(src='https://www.google.co.in/', height=600, width=535)
})
}
shinyApp(ui, server)
Output: Why am I not able to show any website. Please help me, I google a lot and tried many options including the renderUI; htmloutput and uioutput panels.
So the problem you are facing is that the site you were referencing to had the X-Frame-Options
set to sameorigin
. This means that iframes
are basically blocked by the https://www.google.co.in
server.
You can see a corresponding error message in the javascript console which can be acessed with Ctrl+shift+K in google chrome. For other browsers see here.
Certain workarounds and morde discussion about the X-Frame-Options
issue can be found in this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With