R闪亮:添加网页链接到actionButton [英] R shiny: Add weblink to actionButton
问题描述
shiny:在闪亮的应用程序中有一个包含闪亮仪表板框的按钮, :fluidRow(
shinydashboard :: box(title =Intro Page,Some description ...,
shiny :: actionButton(inputId ='ab1',label =了解更多,图标=图标(th))
)
)
我想在按钮中包含一个网页链接,当我点击它时,它应该在新标签中打开相应的网页。
我知道我可以这样做:
#this虽然没有创建提交按钮,但它只是创建一个链接。
标签$ div(class =submit,
tags $ a(href =www.google.com,
了解更多,
target =_ blank )
)
但是使用actionButton,有一个不错的按钮,我可以添加一个图标它看起来更美观。
如何在actionButton中添加一个链接发光?
您可以添加参数
onclick =location.href ='http://google.com';
转到操作按钮并点击它会将您带到当前窗口中的google.com,或者您可以添加
onclick =window.open('http://google.com','_blank')
,您将被带到Google的新标签中
<那就是
shiny :: fluidRow(
shinydashboard :: box(title =Intro Page,一些描述...,
shiny :: actionButton(inputId ='ab1',label =了解更多,
icon =图标(th),
onclick =窗口.open('http://google.com','_blank'))
)
)
I have a box in my shiny application that has a button included within a shiny dashboard box like this:
shiny::fluidRow(
shinydashboard::box(title = "Intro Page", "Some description...",
shiny::actionButton(inputId='ab1', label="Learn More", icon = icon("th"))
)
)
I want to include a weblink in the button such that when I click on it, it should open the corresponding webpage in a new tab.
I know that I can do this instead:
# this does not create a submit button though, it just creates a link.
tags$div(class = "submit",
tags$a(href = "www.google.com",
"Learn More",
target="_blank")
)
But with actionButton, there is a nice button and I can add an icon to it which looks aesthetically better.
How do I add a link to actionButton in shiny?
You can add the parameter
onclick ="location.href='http://google.com';"
To the action button and clicking it will take you to google.com in the current window or you can add
onclick ="window.open('http://google.com', '_blank')"
and you will be taken to Google in a new tab
That is
shiny::fluidRow(
shinydashboard::box(title = "Intro Page", "Some description...",
shiny::actionButton(inputId='ab1', label="Learn More",
icon = icon("th"),
onclick ="window.open('http://google.com', '_blank')")
)
)
这篇关于R闪亮:添加网页链接到actionButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!