質問

Since Firefox is prompting the user to store data when using the HTML5 application cache, I want to disable it in Firefox to avoid the prompt notification.

One way to do that is serving two different HTML files: one for Firefox with <html> and one for the other browsers with <html manifest=...>.

But for efficiency purposes I want to serve one single static file.

So how do I disable the application cache while serving a file with <html manifest=...> in Firefox?

役に立ちましたか?

解決

The manifest attribute isn't checked until the page is loaded. Meaning that you can remove it while the page is loading and the prompt won't appear. Like this:

<script type="text/javascript">
  if (window.navigator.product == "Gecko")
    document.documentElement.removeAttribute("manifest");
</script>

Which of course assumes that all Gecko browsers need to be banned for all eternity because of this prompt. Definitely not nice, particularly because the prompt might disappear at some point in future. But I don't see a proper way to detect whether a browser will prompt the user about storing the web application for offline use.

他のヒント

Use an iframe to install the applicationCache; that way you can prompt a user with a button, and load the iframe once they click on that button.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top