R 闪亮:将网络链接添加到 actionButton [英] R shiny: Add weblink to actionButton

查看:21
本文介绍了R 闪亮:将网络链接添加到 actionButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我闪亮的应用程序中有一个框,它的按钮包含在闪亮的仪表板框中,如下所示:

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.

我知道我可以这样做:

# 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")
)

但是有了 actionButton,有一个很好的按钮,我可以向它添加一个图标,看起来更美观.

But with actionButton, there is a nice button and I can add an icon to it which looks aesthetically better.

如何在闪亮的 actionButton 中添加链接?

How do I add a link to actionButton in shiny?

推荐答案

可以添加参数

onclick ="location.href='http://google.com';"

到操作按钮并单击它会带您到当前窗口中的 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')"

您将在新标签页中转到 Google

and you will be taken to Google in a new tab

那就是

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆