Reputation: 519
Please check the snapshot below. I want to enter the url of any website in the search bar in the left box and the webpage can be displayed real time in the right box. The command "searchInput" I used is a shinyWidget and does not fulfill this. Please help me with a fix here. Also I would like to give a default web page link when the app runs like any site name. Please help me here.
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(title = "Web Page"),
dashboardSidebar(
width = 0
),
dashboardBody(
box(title = "Web Page Search", status = "primary",height = "155"
,solidHeader = T,
uiOutput("search_plot")),
box( title = "Web Page", status = "primary", height = "618",solidHeader = T,
uiOutput("wep_page"))))
server <- function(input, output)
{
output$search_plot <- renderUI({
searchInput(inputId = "Id009",
label = "Enter the address",
placeholder = "A placeholder",
btnSearch = icon("search"),
btnReset = icon("remove"),
width = "100%")
})
output$wep_page <- renderUI({
})
}
shinyApp(ui, server)
Upvotes: 1
Views: 2187
Reputation: 25435
You could do something like this:
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(title = "Web Page"),
dashboardSidebar(
width = 0
),
dashboardBody(
box(title = "Web Page Search", status = "primary",height = "155"
,solidHeader = T,
uiOutput("search_plot")),
box( title = "Web Page", status = "primary", height = "860px",solidHeader = T,
uiOutput("wep_page"))))
server <- function(input, output)
{
output$search_plot <- renderUI({
searchInput(inputId = "Id009",
label = "Enter the address",
btnSearch = icon("search"),
btnReset = icon("remove"),
value='https://',
width = "100%")
})
output$wep_page <- renderUI({
print(input$Id009)
tags$iframe(src=input$Id009,width='100%',height='800px')
})
}
shinyApp(ui, server)
Note that this may require some tweaking. i.e. check that the URL starts with http://
or https://
and probably some error handling, but this may help you in the right direction. Also, not all websites can be rendered in an iframe, for more info see here.
Upvotes: 3