我可以让Chrome或Mozilla为本地文件例如PDF或类似文件提供图标吗?

问题描述

问题是,无图标页面只有一个通用图标。任何解决方案都是有效的,例如将html添加到加载的文件或浏览器的配置中。

解决方法

您可以创建一个带有收藏夹图标的HTML页面,然后向其中添加一个iframe。 尽管这可能不是您想要的,但在此示例中,它将显示带有stackoverflow图标的.png文件。

body {
  margin: 0px;
  padding: 0px;
}

* > iframe.maxsize {
  position: fixed;
  width: 100%;
  height: 100%;
}

.maxsize {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">

  <title>My File</title>

  <link href="https://www.google.com/s2/favicons?domain=stackoverflow.com" rel="icon">
</head>

<body>
  <iframe src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" class="maxsize">
        Your browser does not support iframes!
    </iframe>
</body>

</html>