Chrome中的history.pushState提供收件人图标请求 [英] history.pushState in Chrome make favicon request
问题描述
代码:
var newurl = window.location.protocol +//+ window.location.host + window.location.pathname +?+ queryStr;
window.history.pushState({path:newurl},'',newurl)
每当 window.history.pushState()
时,当前场景
预期情景:
favicon应该只在页面加载时加载一次,我不希望favicon每次加载 window.history.pushState( )
。
favicon路径在HTML页面中的链接如下:
<! - Favicon - >
< link rel =icontype =image / pnghref =../ img / icon / favicon-16x16.pngsizes =16x16>
< link rel =icontype =image / pnghref =../ img / icon / favicon-32x32.pngsizes =32x32>
< link rel =icontype =image / pnghref =../ img / icon / favicon-96x96.pngsizes =96x96>
任何即时帮助将非常可观。感谢
它看起来像 Chromium
浏览器中的一个错误。请参阅此开放问题。
但是,如果您使用 base64
图片作为 href
请求,似乎有一个解决方法将不会发生。
< link rel =icontype =image / pnghref =data:image / png; base64, iVBORw0KGgo =>
请参阅这个问题。
code :
var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname +"?"+ queryStr;
window.history.pushState({path:newurl},'',newurl)
current scenario :
everytime when window.history.pushState()
is invoked favicon requests occur rapidly.It makes network request for favicon on every call of this function.
expected scenario :
favicon should be loaded only once on page load, I would not expect the favicon load on every request of window.history.pushState()
.
favicon paths are link like this in HTML page :
<!-- Favicon -->
<link rel="icon" type="image/png" href="../img/icon/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="../img/icon/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="../img/icon/favicon-96x96.png" sizes="96x96">
Any immediate help will be highly appreciable. Thanks
It looks like a bug in Chromium
browsers. See this open issue.
But there seems to be a workaround if you use base64
image as href
the request won't occur.
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=">
See this question.
这篇关于Chrome中的history.pushState提供收件人图标请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!