Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
304 views
in Technique[技术] by (71.8m points)

Add link to R Shiny Application so link opens in a new browser tab

I am creating my first Shiny Application in R. I am using shiny to display bivariate results from a survey I conducted. From a pair of input boxes users can choose variables from the survey, and various statistics are generated (tables, plots, etc.) allowing them to explore certain attributes of the survey data.

I want to include a link to the actual PDF survey. Right now I have written code so that the PDF survey can be linked to, by clicking on the text "Click here to download survey" which appears as helpText, embedded in a wellPanel, within the pageWithSidebar. I used the following commands (in the ui.R file):

    wellPanel(
    helpText(   a("Click Here to Download Survey",     href="http://www.dfcm.utoronto.ca/Assets/DFCM2+Digital+Assets/Family+and+Community+Medicine/DFCM+Digital+Assets/Faculty+$!26+Staff/DFCM+Faculty+Work+$!26+Leadership+Survey+Poster.pdf")
    )
    )

Is there a way to automatically open this file in a new tab (of IE, Firefox, etc.)? Currently, the functionality is to open the link in the same tab as the shiny app. So you have to use the forward and backwards buttons to go from app to survey and back again.

Right now, I am right clicking the link and selecting "Open in a New Tab". Is there a way to embed this functionality into the back end code so it becomes the default.

Disclaimer: I have no real experience in html or java. I am an avid user of R. If a solution is possible, can you please try to explain where I embed the code changes in the ui.R or server.R files respectively.

question from:https://stackoverflow.com/questions/17861102/add-link-to-r-shiny-application-so-link-opens-in-a-new-browser-tab

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Adding the argument target="_blank" to the function a() worked perfectly. Thanks for the solution @Chase!!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...