Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shiny Iframe not showing any website

Tags:

r

iframe

shiny

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: enter image description here 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.

like image 490
surpavan Avatar asked Nov 07 '22 08:11

surpavan


1 Answers

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.

like image 174
Gregor de Cillia Avatar answered Nov 15 '22 13:11

Gregor de Cillia