我有一个URL随着闪亮的应用程序的输入而变化.我想打开一个网页,并在闪亮的窗口的选项卡面板中显示它.每次我更改输入时,网页URL都会更新,我想在同一个标签页中显示该页面.截至目前,使用R的browseURL函数,网页将在一个单独的窗口中打开,而不是闪亮的窗口.
这是我的案例的小测试示例
ui.R
shinyUI(fluidPage(
titlePanel("opening web pages"),
sidebarPanel(
selectInput(inputId='test',label=1,choices=1:5)
),
mainPanel(
htmlOutput("inc")
)
))
Run Code Online (Sandbox Code Playgroud)
server.R
shinyServer(function(input, output) {
getPage<-function() {
return((browseURL('http://www.google.com')))
}
output$inc<-renderUI({
x <- input$test
getPage()
})
})
Run Code Online (Sandbox Code Playgroud)
不要用browseURL.这将在新窗口中明确打开网页.
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()
})
})
)
Run Code Online (Sandbox Code Playgroud)
如果要镜像页面,可以使用 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()
})
})
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5572 次 |
| 最近记录: |