[英]gulp: how to update the browser without refresh (for css changes only)
[英]reload css in browser without refresh
我有這樣的情況,我必須對css文件進行一些更改並為此重新加載它,但是我需要刷新瀏覽器以反映這些更改,請幫助
$.ajax({
type: "POST",
url: "handlers/load-css-file.ashx",
data: { colorCode: colorCode, defaultColor: defaultColor,currentCss:currentCss },
dataType: 'text',
async: false,
success: function () {
_edSite.theme = currentCss;
edLoadCss(_workUrl + _edSite.theme);
},
error: function () {
alert("Please try after some time.");
}
});
//loading css file on the website
function edLoadCss(href) {
var cssLink = $("<link rel='stylesheet' type='text/css' href='" + href + "'>");
$("head").append(cssLink);
};
我不想為此重新加載瀏覽器。
試試這個代碼:
$.ajax({
type: "POST",
url: "handlers/load-css-file.ashx",
data: { colorCode: colorCode, defaultColor: defaultColor,currentCss:currentCss },
dataType: 'text',
async: false,
success: function () {
_edSite.theme = currentCss;
edLoadCss(_workUrl + _edSite.theme);
},
error: function () {
alert("Please try after some time.");
}
});
//loading css file on the website
function edLoadCss(href) {
var d = new Date();
$("link [rel=stylesheet]").attr("href", href + "?" + d.getTime());
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.