Changing website favicon dynamically

前端 未结 15 1508
温柔的废话
温柔的废话 2020-11-22 02:17

I have a web application that\'s branded according to the user that\'s currently logged in. I\'d like to change the favicon of the page to be the logo of the private label,

15条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 02:44

    Yes totally possible

    • Use a querystring after the favicon.ico (and other files links - see answer link below)
    • Simply make sure the server responds to the "someUserId" with the correct image file (that could be static routing rules, or dynamic server side code).

    e.g.

    
    

    Then whatever server side language / framework you use should easily be able to find the file based on the userId and serve it up in response to that request.

    But to do favicons properly (its actually a really complex subject) please see the answer here https://stackoverflow.com/a/45301651/661584

    A lot lot easier than working out all the details yourself.

    Enjoy.

提交回复
热议问题