6

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.

3
  • 2
    I can confirm that both your example or the example in the linked questions show a blank iframe. The javascript console gives me the error Refused to display 'https://www.google.co.in/' in a frame because it set 'X-Frame-Options' to 'sameorigin'. in both cases. See here for more reference. Apr 15, 2018 at 14:31
  • Thank you @GregordeCillia - I checked a local web server and it working. Google is a common site tot check with in general so did not check other sites earlier. Please submit it as an answer - I will mark it complete; but R console did not throw it as an error. How can I know such cases?
    – surpavan
    Apr 15, 2018 at 18:27
  • I just postet an answer and included a keyboard shortcut for acessing the JavaScript console. Quite a few error messages in JavaScript are not returned to R by shiny so I would suggest to check this console every now and then to keep your apps stable. Apr 15, 2018 at 19:26

1 Answer 1

3

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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.