【问题标题】:Setting the favicon for all pages设置所有页面的图标
【发布时间】:2013-11-13 07:38:15
【问题描述】:

以下代码用于显示网站图标:

<head>
    <title><link rel="icon" href="/favicon.ico" type="image/x-icon" /></title>
</head>

我的图片路径是:wamp/www/widget_corp/favicon.ico

页面的 URL 是:localhost/widget_corp/pat_apt.php

问题是:我无法显示网站图标。谁能告诉我为什么?另外,建议我为所有页面显示 favicon 的方式。我浏览了一些他们建议编辑配置文件的论坛。真的吗? 我正在使用 WAMP 服务器 2.4

【问题讨论】:

    标签: html wamp favicon


    【解决方案1】:

    不要在标题标签中嵌入您的网站图标代码。 这就是你看不到它的原因。

    要在不同的页面中包含相同的代码,请创建一个 php 文件来包含您的头部信息:

    header.php

    <link rel="icon" href="/favicon.ico" type="image/x-icon" />
    

    然后在所有页面的 head 标签之间调用它:

    <head>
      <title>My Title</title>
      <? require_once 'header.php'; ?>
    </head>
    

    【讨论】:

    • 我的 header.php 在包含文件夹中。我在那里粘贴了网站图标并修改了文件以设置链接但是我没有得到图像?
    • 如果你的 header.php 在包含文件夹中,你应该尝试从父文件夹中获取它:&lt;link rel="icon" href="../favicon.ico" type="image/x-icon" /&gt;
    【解决方案2】:

    使用这个:

    <head>
        <link rel="icon" href="../widget_corp/favicon.ico" type="image/x-icon" />
    </head>
    

    您应该只将页面的标题文本放在&lt;title&gt; 中。

    【讨论】:

      猜你喜欢
      • 2010-11-02
      • 2011-02-19
      • 2017-03-19
      • 1970-01-01
      • 2021-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多