Favicon in Shiny

后端 未结 4 1714
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 23:33

I wanted to add a favicon to my WebApp

I\'m using this line, but it doesn\'t work:

HTML(\"

        
相关标签:
4条回答
  • 2020-12-06 00:22

    A possible problem the OP is having is that the favicon filename should be favicon.ico and not image.png.

    Some additional details here: favicon.png vs favicon.ico - why should I use PNG instead of ICO?

    The important part being:

    All modern browsers (tested with Chrome 4, Firefox 3.5, IE8, Opera 10 and Safari 4) will always request a favicon.ico unless you've specified a shortcut icon via . So if you don't explicitly specify one, it's best to always have a favicon.ico file, to avoid a 404.

    0 讨论(0)
  • 2020-12-06 00:28

    If you're using a local runapp, then putting one in /www/favicon.ico should work, I believe.

    You could also insert this somewhere in your UI:

    tags$head(tags$link(rel="shortcut icon", href="URL-to-favicon"))

    Joe Cheng

    0 讨论(0)
  • 2020-12-06 00:32

    You can convert your favicon into base64 text (check favicon.cc website, they already do it) and write:

    ui <- function(){tagList(
    
    fluidPage(
    
    
    titlePanel(
      windowTitle = "Title that appears in the browser bar",
      title = tags$head(tags$link(rel="icon", 
                                  href="data:image/x-icon;base64,AAABAAEAEBAQAAEAetc", 
                                  type="image/x-icon")
                        )),
    
    sidebarLayout( sidebarPanel(
    
    0 讨论(0)
  • 2020-12-06 00:36

    I was able to get favicon to work in r shiny using this code on both internet explorer and chrome:

    ui <- fluidPage(
      titlePanel(
        windowTitle = "NOAA",
        title = tags$head(tags$link(rel="shortcut icon", 
                                    href="https://www.noaa.gov/sites/all/themes/custom/noaa/favicon.ico", 
                                    type="image/vnd.microsoft.icon")))
    ###... rest of code
    )
    
    server <- function(input, output, session) {
    ###... rest of code
    }
    
    runApp(shinyApp(ui = ui, server = server), launch.browser = TRUE)
    
    0 讨论(0)
提交回复
热议问题