我使用PHP来设置我的图标
<link rel="shortcut icon" href="<?php echo "/SysFiles/img/ico/". $favicon; ?>">
这适用于Firefox但不适用于Chrome。每当图标发生变化时,如何让Chrome重新获得图标?
编辑:这个文件位于/SysFiles/navbar.php,服务器上的每个页面都包含PHP,包括我正在测试的页面
编辑: navbar.php
<?php
session_start();
if ($_COOKIE['darktheme'] == "1") {
$_SESSION['darktheme'] = true;
$_SESSION['SETHEME'] = 1;
} else {
$_SESSION['darktheme'] = false;
$_SESSION['SETHEME'] = 1;
}
$addr = "http://" . $_SERVER['SERVER_ADDR'];
$myfile = fopen("$addr/Data/Points/makarios", 'r');
$makarios = fgets($myfile);
fclose($myfile);
$myfile = fopen("$addr/Data/Points/sozo", 'r');
$sozo = fgets($myfile);
fclose($myfile);
$myfile = fopen("$addr/Data/Points/kaleo", 'r');
$kaleo = fgets($myfile);
fclose($myfile);
$myfile = fopen("$addr/Data/Points/katharos", 'r');
$katharos = fgets($myfile);
fclose($myfile);
$myfile = fopen("$addr/Data/Points/charis", 'r');
$charis = fgets($myfile);
fclose($myfile);
$myfile = fopen("$addr/Data/Points/agape", 'r');
$agape = fgets($myfile);
fclose($myfile);
$cookie_name = "REENT";
$cookie_value = $makarios + $sozo + $kaleo + $katharos + $charis;
if ($cookie_value != $_COOKIE["REENT"]) {
$newcooksit = true;
}
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");
if ($newcooksit == true) {
echo '<br><br><br><div class="alert alert-info"><strong>Look!</strong> Points have changed since your last visit! Check the new values <a href="results.php">here!</a> </div>';
} else {
echo '<br><br><br>';
}
?>
<?php
$sid = $_SERVER['SERVER_ADDR'];
$items = ["/SysFiles/img/ico/makarios.ico", "/SysFiles/img/ico/agape.ico", "/SysFiles/img/ico/kaleo.ico", "/SysFiles/img/ico/charis.ico", "/SysFiles/img/ico/sozo.ico", "/SysFiles/img/ico/katharos.ico"];
//echo $items[array_rand($items)];
$ico = $items[array_rand($items)];
?>
<head>
<meta charset="utf-8">
<?php $favicon = $_COOKIE['houseicn']; ?>
<link rel="icon" href="<?php echo "/SysFiles/img/ico/". $favicon; ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<?php
if ($_SESSION['darktheme'] == true) {
?>
<link rel="stylesheet" type="text/css" href="SysFiles/sys/darktheme.css">
<?php
}
?>
</style>
</head>
<?php
if ($_SESSION['darktheme'] == true) {
?>
<font color='white'>
<?php
}
if ($_SERVER['SETHEME'] == 1) {
if ($_SERVER['SETHEMED'] !== 1) {
header("Refresh:0");
}
$_SERVER['SETHEMED'] == 1;
}
?>
<?php
if ($_SESSION['ACCESS'] > 0) {
?>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="index.php">House Points</a>
</div>
<ul class="nav navbar-nav">
<li><a href="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/index.php">Home</a></li>
<li><a href="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/results.php">Current Results</a></li>
<li><a href="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/archive.php">Old Results</a></li>
<li><a href="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/submit.php">Teacher Submission</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/logout.php"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> Logout</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">About
<span class="caret"></span></a>
<ul class="dropdown-menu">
<?php include "sysinfo"; ?>
</ul>
</li>
</ul>
</div>
</nav>
<?php } else { ?>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="index.php">House Points</a>
</div>
<ul class="nav navbar-nav">
<li><a href="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/index.php">Home</a></li>
<li><a href="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/results.php">Current Results</a></li>
<li><a href="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/archive.php">Old Results</a></li>
<li><a href="http://<?php echo $_SERVER['SERVER_ADDR']; ?>/submit.php">Teacher Submission</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">About
<span class="caret"></span></a>
<ul class="dropdown-menu">
<?php include "sysinfo"; ?>
</ul>
</li>
</ul>
</div>
</nav>
<?php } ?>
答案 0 :(得分:1)
根据bugs.chromium.org/p/chromium/issues/detail?id=51270,有一个错误阻止Chrome无法通过网络路径获取图标。
尝试完全限定网址,如:
public static AppUserManager Create(IdentityFactoryOptions<AppUserManager> options, IOwinContext context)
{
EFDbContext db = context.Get<EFDbContext>();
AppUserManager manager = new AppUserManager(new UserStore<AppUser>(db));
// etc.
return manager;
}
答案 1 :(得分:0)
我个人,只要我记得,就没有使用rel="shortcut icon"
。只需使用:
<link rel="icon" href="<?php echo "/SysFiles/img/ico/". $favicon; ?>">
应该做的伎俩。在Chrome和Firefox中测试和工作(对我来说一直都是这样)。相对路径也是如此。不是绝对的。
破解缓存的方法,如果需要:
/favicon.ico
至favicon2.ico
http://example.com/path/to/favicon.ico
。按输入。然后多次按 Ctrl + Shift + R 直到它发生变化。<link>
中的.ico路径附加一个查询字符串,例如。 <link rel="icon" href="http://example.com/path/to/favicon.ico?foo=bar">