最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - How does this site (allaboutrajni) works only when you go offline? (disconnect from internet) - Stack Overflow

programmeradmin4浏览0评论

The following site only works if you are offline. Link

So how do they do this?

I have even seen Youtube do something similar. just open YouTube and disconnect net and refresh. You will see the page below.

The following site only works if you are offline. Link

So how do they do this?

I have even seen Youtube do something similar. just open YouTube and disconnect net and refresh. You will see the page below.

Share Improve this question edited Aug 21, 2014 at 10:42 aWebDeveloper asked Apr 2, 2012 at 12:41 aWebDeveloperaWebDeveloper 38.5k41 gold badges178 silver badges247 bronze badges 4
  • 1 This message is created by Google Chrome, not Youtube. When you are disconnected, you are disconnected. – Ben Carey Commented Apr 2, 2012 at 12:45
  • HTML5 has local storage which supports offline websites – huysentruitw Commented Apr 2, 2012 at 12:47
  • 1 8 upvotes??? what on earth does this question have?? – pho Commented Apr 3, 2012 at 4:12
  • @PranavHosangadi that's the power of Rajani ;) – aWebDeveloper Commented Apr 3, 2012 at 6:10
Add a ment  | 

4 Answers 4

Reset to default 7

HTML5 allows webpages to work offline by;

  1. Providing storage in terms of localStorage and sessionStorage.
  2. Providing events to let the page know when it's online/ offline
  3. The navigation.onLine property is a boolean which lets you know whether you're online or not.
  4. Giving application caches.

So basically, both pages store the assets it needs to work offline in either of those storage mediums, and checks whether it's online or offline when the page loads.

For more info, you could see http://www.html5rocks./en/features/offline

EDIT: Meh, infact the site you linked to works by downloading the flash content, and then pinging http://images.desimartini./allaboutrajni/config.xml every second to detect whether it's still connected to the internet. This website won't load if you disconnect and then refresh the page.

However, a page which uses true offline functionality is one such as http://htmlfive.appspot./static/stickies.html

this as you can see is basically an entire site embedded in flash. so when you click on the url the entire site in flash is downloaded to the client browser and hence no more internet connection is required to run the site. also you can check for internet connection using action script as given here and enable access to user only if net is disconnected.

I think http://www.desimartini./allaboutrajni.htm works offline because its flash and so when you visit the site the fist time, the flash get donwloaded and can run afterwards without internet connection. To prove it, turn off your internet before visiting the site, you will notice that it does not load up. Second, youtube works because its owned by google and your are using google chrome to view it. Google chrome must have added custom code to their to browser to detect when users are trying to view youtube without an internet connection.

I have done this before using PHP. Basically create a loader than look for a file named check.php than on your loader class create an if statment. in your php or text file just add a variable onlineChecker = ok if some one downloads your flash movie its still hard for them to watch as they dont have the checking file on their pc or know it exists to they unpile it.

var onlineChecker = ""
var myRequest:URLRequest = new URLRequest("test.php");
var myLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, onload);
myLoader.load(myRequest);


function onload(){
if(onlinechecker == ok){
  // well now we are not going to load nothing or continue.
else{
  gotoAndPlay(whatever);
  }
 }

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论