Opening web pages in a shiny window without opening a separate window

I have a url that changes with input on a brilliant app. I want to open a webpage and show it using the tab bar of a shiny window. Every time I change the login, the URL of the webpage is updated and I want to show this page on the same tab. At the moment, the web page opens in a separate window than in a shiny window using the browseURL R.

here is a small test example for my case

ui.R

shinyUI(fluidPage( titlePanel("opening web pages"), sidebarPanel( selectInput(inputId='test',label=1,choices=1:5) ), mainPanel( htmlOutput("inc") ) )) 

server.R

 shinyServer(function(input, output) { getPage<-function() { return((browseURL('http://www.google.com'))) } output$inc<-renderUI({ x <- input$test getPage() }) }) 
+8
r shiny
source share
1 answer

Do not use browseURL . This clearly opens the web page in a new window.

 library(shiny) runApp(list(ui= fluidPage( titlePanel("opening web pages"), sidebarPanel( selectInput(inputId='test',label=1,choices=1:5) ), mainPanel( htmlOutput("inc") ) ), server = function(input, output) { getPage<-function() { return((HTML(readLines('http://www.google.com')))) } output$inc<-renderUI({ x <- input$test getPage() }) }) ) 

If you want to mirror the page, you can use iframe

 library(shiny) runApp(list(ui= fluidPage( titlePanel("opening web pages"), sidebarPanel( selectInput(inputId='test',label=1,choices=1:5) ), mainPanel( htmlOutput("inc") ) ), server = function(input, output) { getPage<-function() { return(tags$iframe(src = "http://www.bbc.co.uk" , style="width:100%;", frameborder="0" ,id="iframe" , height = "500px")) } output$inc<-renderUI({ x <- input$test getPage() }) }) ) 
+7
source share

All Articles