如果链接到在线css文件已死,请使用本地css文件 [英] Use local css file if link to online css file is dead
问题描述
问题:
我使用 w3.css (如果您现在输入 w3schools .com
网站停止维护)为样式我的网站。问题在这里是 w3schools.com
从时代到时代。 / p>
然后我的网站看起来令人毛骨悚然,我不需要。
w3.css
。
在线:
< link rel =stylesheethref =http://www.w3schools.com/lib/w3.css>
本地:
code>< link rel =stylesheethref =../ css / w3.css>
问题:
我如何知道我指向的链接 w3schools
是死的,所以我可以使用本地 w3.css
文件。我可以这样做吗?
strong> 1 )检测是否已损坏
2 b
$ b
最后
大公司为此做了什么?如果 3-4
Web服务下降整个公司正在下降.....
我是网络开发的新人。谢谢你。
strong>编辑:(我有一些想法)
在服务器上加载 c> w3schools
文件,但这将增加网站加载...
检查如果w3.css是工作,你可以使用这样的东西。而不是src将w3.css图片的标志或东西。
function checkImage (src,up,down){var img = new Image(); img.onload = up; img.onerror = down; img。 src = src;} checkImage(https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png,function(){alert(up);},function(){ alert(down);});
The problem:
I am using w3.css(if you enter now w3schools.com
site is down for maintenance) for styling my website.The problem here is that w3schools.com
is going down from times to times.
Then my website looks creepy and i don't need that.
So i have a local copy of the w3.css
on the computer and up to the server which is holding the website.
Online:
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
Local:
<link rel="stylesheet" href="../css/w3.css">
The question:
How i know when the link which i am pointing on w3schools
is dead,so i can use the local w3.css
file.How i can do that?
1)Detect if broken
2)Use the local css before the website has been loaded
Finally
What big companies are doing for that?If 3-4
WebServices go down the whole company is going down.....
I am new to web developing so..Thank you...
Edit:(I have something in mind)
Loading the local(...site in on a server,that local i mean)
and the w3schools
file , but that will increase the site loading...
for check if w3.css is working you can use something like this. instead of src put w3.css image of logo or something .
function checkImage (src, up, down) {
var img = new Image();
img.onload = up;
img.onerror = down;
img. src = src;
}
checkImage( "https://www.google.co.in/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", function(){ alert("up"); }, function(){ alert("down"); } );
这篇关于如果链接到在线css文件已死,请使用本地css文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!