简体   繁体   中英

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 .

Based on your comment, that you are able to use PHP, you could use this code:

<?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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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