Вопрос

Okay, this is a problem I have been having for sometime now, and I cant find a solution, Anywhere!

My Problem:

My HTML content is available as web application that can be used offline, but I want the contact form to also be available offline.

Is there anyway the user can fill in the contact form when they have no connection and then for a script to run that holds that inputted data until a connection is established.

And then once the connection is established for the data to be sent to a PHP script on a server?

Edit:

Thanks for all your answers! I have looked into local storage but this doesnt work as the user may revist the page but they still probably wont have an internet connection, so I was wondering if there is any type of script that can run locally all the time until there is an established internet connection

Thank you in advance!

Это было полезно?

Решение 2

Yes - provided that they open your page again with an internet connection at a later date.

The steps are:-

  1. Try and send message (AJAX etc.)
  2. If it fails due to no connection - store to localstorage.
  3. Have a loop that checks for messages in local storage.
  4. If message found try to re-send.
  5. Once message is sent remove it from local storage. (AJAX success)

Другие советы

You can not run a script unless the page is opened.

The only way around this would be to create a Chrome Extention or FireFox Addon:

http://en.wikipedia.org/wiki/Google_Chrome_Extensions

http://en.wikipedia.org/wiki/Add-on_(Mozilla)

That is indeed possible if the website stays open.

You can have a javascript loop that checks some recource (i.e. a tiny json file on your server) and if it can read this successfully, it attempts to send the email/data.

If it is not, it waits for a certain time using timeout.

You'll surely be able to find examples of this on the internet since this is often used in modern web development due to the often unstable connection of smartphones.

you can try local storage to store the data and retrieve it after the browser re-opens Or cookies.

If you use mozilla you can hack the XUL codes and inject your scripts into it. Otherwise you must hack the browser template which supports js

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top