Add a twitter share button to shiny R navbar

后端 未结 1 1083
独厮守ぢ
独厮守ぢ 2020-12-15 14:21

Trying to add a twitter share button to my navbar. The closet I can get is to place it in the header, but this leaves too much white space. I would like it to go in the top

相关标签:
1条回答
  • 2020-12-15 15:12

    You could try adding the div directly to the navbar using jQuery by adding this after your last tabPanel:

    tags$script(HTML("var header = $('.navbar > .container');
                           header.append('<div style=\"float:right\"><a href=\"https://twitter.com/share\" class=\"twitter-share-button\" aling=\"middle\" data-url=\"www.mywebsite.com\" data-text=\"Visit www.mywebsite.com\" data-size=\"large\">Tweet</a></div>');
                           console.log(header)")),
        tags$script(HTML("!function(d,s,id){
                var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
                if(!d.getElementById(id)){
                        js=d.createElement(s);
                        js.id=id;
                        js.src=p+'://platform.twitter.com/widgets.js';
                        fjs.parentNode.insertBefore(js,fjs);
                }
        }(document, 'script', 'twitter-wjs');"))
    
    0 讨论(0)
提交回复
热议问题