简体   繁体   English

根据Internet可用性从在线样式表切换到离线样式表

[英]Switching From Online to Offline Stylesheets Based on Internet Availability

Question / Problem: Is it possible to automatically switch between online stylesheet to offline stylesheets? 问题:是否可以在在线样式表和离线样式表之间自动切换?

For example , here in the office whenever I developed a site I need to connect to live bootstrap stylesheet, but whenever I go home I need offline stylesheet. 例如 ,在办公室中,每当我开发一个网站时,我都需要连接到实时引导样式表,但是每当我回家时,我都需要脱机样式表。 I'm tired of commenting the stylesheets to be used. 我讨厌评论要使用的样式表。 Is there any way? 有什么办法吗?

Conclusion: Thanks to all, by using the code of linkinTED I've solved this problem of mine . 结论:归功于所有,通过使用linkinTED的代码, 我解决了我的这个问题

Based on your comment, that you are able to use PHP, you could use this code: 根据您的评论,您可以使用PHP,可以使用以下代码:

<?php

$extUrl = 'http://www.somesite.com/stylesheet.css';
$intUrl = 'css/stylesheet.css';

$url = ( @fopen( $extUrl, "r" ) ) ? $extUrl: $intUrl;

echo '<link rel="stylesheet" href="' . $url . '" />';

?>

No, you can't. 不,你不能。 You have to use a server-side technology/framework that allows to set up different configurations for your website and makes it easy to switch between one configuration and the other 您必须使用服务器端技术/框架,该技术/框架可以为您的网站设置不同的配置,并且可以轻松地在一种配置和另一种配置之间切换

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM