Html 如何处理增加web存储的提示?

Html 如何处理增加web存储的提示?,html,mobile,web-sql,web-storage,Html,Mobile,Web Sql,Web Storage,当您达到web sql存储的大小限制时,Mobile Safari(和Android浏览器)将提示您增加存储大小。一旦发生这种情况,事务、onSuccess回调或onError回调都不会执行。我在这里似乎也不能捕捉到任何异常,那么我应该如何处理增加存储的提示呢 所有操作都是异步的,因此我只能考虑设置一个超时,并检查事务是否在一段时间后完成。这当然是一个讨厌的,虫子缠身的黑客。除此之外,我还必须重新进行事务处理,以实际检查空间是否增加 上面代码的问题基本上是,我缺少一个用于包装sql插入的事务的

当您达到web sql存储的大小限制时,Mobile Safari(和Android浏览器)将提示您增加存储大小。一旦发生这种情况,事务、onSuccess回调或onError回调都不会执行。我在这里似乎也不能捕捉到任何异常,那么我应该如何处理增加存储的提示呢

所有操作都是异步的,因此我只能考虑设置一个超时,并检查事务是否在一段时间后完成。这当然是一个讨厌的,虫子缠身的黑客。除此之外,我还必须重新进行事务处理,以实际检查空间是否增加


上面代码的问题基本上是,我缺少一个用于包装sql插入的事务的错误回调。有关如何实际处理用户提示的更多信息,请参见此

没有示例代码显示这一点,因此我继续假设使用
事务
方法时没有回调

因此,与其写作

db.transaction(function (tx) {
 // if this prompts the user to increase the size it will not execute the sql or run any of the callbacks
 tx.executeSql('INSERT INTO foo (id, text) VALUES (1, createReallyBigString('4MB')', onComplete, onError );
 });
这样做

// Note the reverse order of the callbacks!
 db.transaction(function (tx) {
 // this will prompt the user to increase the size and the sql will not be executed
 tx.executeSql('INSERT INTO foo (id, text) VALUES (1, createReallyBigString('4MB')');
 }, onError, onComplete );

上面代码的问题基本上是,我缺少一个用于包装sql插入的事务的错误回调。有关如何实际处理用户提示的更多信息,请参见此

没有示例代码显示这一点,因此我继续假设使用
事务
方法时没有回调

因此,与其写作

db.transaction(function (tx) {
 // if this prompts the user to increase the size it will not execute the sql or run any of the callbacks
 tx.executeSql('INSERT INTO foo (id, text) VALUES (1, createReallyBigString('4MB')', onComplete, onError );
 });
这样做

// Note the reverse order of the callbacks!
 db.transaction(function (tx) {
 // this will prompt the user to increase the size and the sql will not be executed
 tx.executeSql('INSERT INTO foo (id, text) VALUES (1, createReallyBigString('4MB')');
 }, onError, onComplete );

相关的:相关的:很高兴听到它帮助了某人,谢谢你的投票:)很高兴听到它帮助了某人,谢谢你的投票:)