15

I want to put a HTML link (actually it redirects to file://...) on the R Shiny user interface, so that end-users can just click it and go to that page in another tab in Chrome. Is there a way to do that? Where shall I put? In the ui.R file or in the server.R file?

I find a post here: http://www.r-bloggers.com/more-explorations-of-shiny/ but I am not sure how to use the a() function...

Note: I know how to do that (see my comments below), but since I am redirecting to a file:// destination, the link won't work. Any solutions?

Thanks!

alittleboy
  • 10,616
  • 23
  • 67
  • 107

1 Answers1

9

Something like this should work:

doc <- tags$html(
   tags$body(
    a(href="http://www.lalala.com"))
)
cat(as.character(doc))

<html>
  <body>
    <a href="http://www.lalala.com"></a>
  </body>
</html>
agstudy
  • 119,832
  • 17
  • 199
  • 261
  • 10
    thanks! actually I found adding `h5("Hello!", a("Link", href="file://blabla.html"))` will work, however since I am using `file://` instead of `http://`, when I click the link, there is no response. Do you know how to get the `file://` stuff done? – alittleboy Jul 25 '13 at 02:29
  • Under windows ...try this `file:///c:/folder/` or use local reference using sub directories... – agstudy Jul 25 '13 at 02:36
  • thanks! unfortunately the HTML which `file://` points to is on a Unix server... and the /// method won't work...:( – alittleboy Jul 25 '13 at 02:42
  • @alittleboy see [this](http://stackoverflow.com/questions/5317834/workaround-for-href-file-in-firefox) for example....seems that you need 5 slash's.... – agstudy Jul 25 '13 at 02:45
  • sorry it still cannot open in a new tab. but if i choose to copy the link and paste and go in another tab, it works. I use chrome, and it seems it's not file:// friendly... – alittleboy Jul 25 '13 at 02:57
  • 2
    @alittleboy little bad question with a long infinite discussion! I dont' know if you are aware of this problem from the beginning or you discover them ...Looks like there are some workaround like installing this [extension](https://chrome.google.com/webstore/detail/locallinks/jllpkdkcdjndhggodimiphkghogcpida). I am not even sure that it can be considered as an R question now. – agstudy Jul 25 '13 at 03:14
  • thank you so much for the extension information! at least for now I can get around it... :) – alittleboy Jul 25 '13 at 03:26