shiny: open new browser tab from within shiny app

时间秒杀一切 提交于 2020-01-01 12:01:08

问题


From within shiny I want to open a HTML page in a new browser tab. Here it is pointed out that I need JS for that task. Let's say I want to open the URL http://www.google.com in a new tab from within my shiny app. I am not familiar with JS yet and I do not know which code where to include and how to call it from within the shiny app. How can I go about it?


回答1:


You shouldn't need anything more fancy than traditional, shiny-ified HTML:

a("test", href="http://google.com", target="_blank")  

You're just looking to set the target attribute on the a tag which tells your browser where to open this new link you created.




回答2:


I was having a problem similar to this so I thought I would add my solution.

I wanted to have links in the tabPanel but Shiny will open a new blank page and have a link instead of just clicking on the tabPanel and opening a new page. Using the standard bootstrap CSS the workaround is to use the navbarMenu and then put the links in the tabPanel.

navbarMenu("Links",
           tabPanel(
               a("Google", href="https://google.com", target="_blank")
           )


来源:https://stackoverflow.com/questions/17502661/shiny-open-new-browser-tab-from-within-shiny-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!