html - 在 R Shiny 标题中制作图像超链接

标签 html r hyperlink shiny

我一直在尝试将图像输出超链接到一个网站,但我无法仔细阅读有关堆栈溢出的其他问题

svg with clickable links in shiny - not clickable

http://www.invisiblecompany.com/shiny%20parts/archives/2004/11/clickable-logo.php

http://www.leahkalamakis.com/add-an-image-to-your-sidebar-make-it-clickable/

标签不工作

服务器.r

library(shiny)
library(png)


server <- shinyServer(function(input, output) { 

output$image1 <- renderImage({
  width<- "100%"
  height<- "100%"
list(src = "www/logo.png",
     contentType = "image/png",
     width = width,
     height = height,
)

}, deleteFile = FALSE)
output$text1 <- renderText({ "please help make the image hyperlinked"     })


})

用户界面

library(shiny)



ui <- shinyUI(pageWithSidebar(
 titlePanel(imageOutput("image1")),

sidebarPanel(
  helpText(   a("Click Here for the Source Code on Github!",         href="https://github.com/Bohdan-Khomtchouk/Microscope",target="_blank"))

 ),
 mainPanel(
tabsetPanel(


  tabPanel("Instructions",textOutput("text1"))
))
))

你可以用你想要的任何东西替换 logo.png 我认为超链接在服务器的列表中。

最佳答案

只需将 imageOutputtags$a 包装起来,这样在 UI 中:

titlePanel(tags$a(imageOutput("image1"),href="https://www.google.com"))

如果你想从服务器端定义网页,那么你需要这样的东西:

#server
  output$example <- renderUI({
    tags$a(imageOutput("image1"),href="https://www.google.com")
  })
#UI
titlePanel(uiOutput("example"))

关于html - 在 R Shiny 标题中制作图像超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38558827/

相关文章:

html - Zurb Foundation 更改顶栏颜色

jquery - CSS 缩放属性不起作用 (Jquery)

javascript - 如何根据父元素的大小制作动态字体大小?

每组重新安排一张 table

r - 将第一行作为我的数据框的列名称,在 R 中使用 dplyr

java - Wicket:创建指向数据表中行的动态 anchor 链接

html - 当外部 div 宽度动画为 0px 时保留内部 div 宽度

r - 在 `dplyr` 中,当使用 `pivot_wide` 时,我想同时替换 'NA'

ruby-on-rails - Ruby on Rails - 不使用资源路由的路径变量

css - 如果选择了链接,请降低其余链接的不透明度