locked
How to use ApplicantionCache?

    Question

  •  I use Iframe to show a website which support HTML 5 offline storage. I wrote following code:

        document.getElementById("iframe").contentWindow.applicationCache.addEventListen('checking',fu1);

      window.applicationCache.addEventListen('checking',fu2);

    document.getElementById("iframe").src = "http://offline.html";

    but the fu1 and fu2 never been invoked.

    Thursday, February 16, 2012 7:54 AM

Answers

All replies

  • Hi H,

    Here is the documentation on Metro style application cache:

    http://msdn.microsoft.com/en-us/library/windows/apps/hh465686.aspx

    Did you follow this?  Did you make the necessary manifest file modifications?

    -Jeff


    Jeff Sanders (MSFT)

    Thursday, February 16, 2012 1:37 PM
    Moderator
  • Hi Jeff,
      I followed link.
      When I unplug the network cable,I can also show the web page. I just can't receive the message.
    Friday, February 17, 2012 8:40 AM
  • Hi H,

    OK I think I understand.  The cache is working fine but the event ('checking') is not firing for you correct?  I will see if I can duplicate the issue and investigate further here.

    -Jef


    Jeff Sanders (MSFT)

    Friday, February 17, 2012 12:42 PM
    Moderator
  • Hi H,

    I was about to start with the repro and realized your problem.  You have a spelling error.  If you enabled 1st chance exceptions in you js file you would have been informed of this when you hit this line.

    Change: addEventListen to: addEventListener in all cases.

    -Jeff


    Jeff Sanders (MSFT)

    Friday, February 17, 2012 6:44 PM
    Moderator
  • Hi jeff,

        I am sorry that "addEventListen" is just a mistake when I wrote this question. I am sure it is "addEventListener" in my code. But it doesn't work. Does the event ('checking') firing in your code? And could you share your code?

        Thank you very much!

    Monday, February 20, 2012 3:14 AM
  • Hi H,

    I can use addEventListener in a page that is hosted in an iframe and in IE 10.  What is your specific scenario?  Are you trying to use it in your app html itself?

    Would you please post a very simple repro of the problem build from a basic blank app?

    Thanks,

    -Jeff


    Jeff Sanders (MSFT)

    Monday, February 20, 2012 8:12 PM
    Moderator
  • Hi Jeff,

        I want to use "iframe" to show the web page which supported offline storage in my metro app, and want to know whether this page is downloaded from the server or from local.

    <body>
    <iframe id="content" src="http://offline.html"></iframe>
    </body>
     document.getElementById("iframe").contentWindow.applicationCache.addEventListen('noupdate',onnoupdate);


    Tuesday, February 21, 2012 5:30 AM
  • I misunderstand this API. Only the page at server can receive this event. Thank you for your help. 
    Wednesday, March 7, 2012 6:48 AM