Created
February 10, 2014 08:39
-
-
Save zsmynl/8912387 to your computer and use it in GitHub Desktop.
使用localStorage保存页面内容。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 保存填写内容 begin */ | |
<script type="text/javascript"> | |
function saveMyContent(){ | |
if(window.localStorage){ | |
var items=["bugtitle","description","editor_content","editor_content1","editor_content2","usertags"]; | |
$.each(items,function(k,v){ | |
var inputValue=$("#"+v).val(); | |
if (inputValue==null ||inputValue==""){ | |
inputValue=""; | |
}else{ | |
inputValue=$("#"+v).val(); | |
} | |
localStorage.setItem(v,inputValue); | |
}); | |
} | |
} | |
function restoreMyContent(){ | |
if(window.localStorage){ | |
var items=["bugtitle","description","editor_content","editor_content1","editor_content2","usertags"]; | |
$.each(items,function(k,v){ | |
var inputStorageValue=localStorage.getItem(v); | |
if(inputStorageValue==null||inputStorageValue==""){ | |
$("#"+v).val(""); | |
}else{ | |
$("#"+v).val(localStorage.getItem(v)); | |
} | |
}); | |
} | |
} | |
saveContentInt=setInterval(saveMyContent,10000); | |
$(function(){ | |
restoreMyContent(); | |
}); | |
</script> | |
/* 保存填写内容 end */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment