7

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.

enter image description here

4
  • 1
    This message is created by Google Chrome, not Youtube. When you are disconnected, you are disconnected.
    – Ben Carey
    Apr 2, 2012 at 12:45
  • HTML5 has local storage which supports offline websites Apr 2, 2012 at 12:47
  • 1
    8 upvotes??? what on earth does this question have??
    – pho
    Apr 3, 2012 at 4:12
  • @PranavHosangadi that's the power of Rajani ;) Apr 3, 2012 at 6:10

4 Answers 4

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.com/en/features/offline

EDIT: Meh, infact the site you linked to works by downloading the flash content, and then pinging http://images.desimartini.com/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.com/static/stickies.html

0
0

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.

0

I think http://www.desimartini.com/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.

0
0

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 uncompile 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);
  }
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.