我要在本地客户端使用localStorage存储配置的一些参数信息,然后在另外一个页面进行调取。
<script type="text/javascript">
layer.config({
skin: 'layer-ext-seaning',
extend: 'skin/seaning/style.css'
});
//清空localStorage的值
//window.localStorage.clear();
var jsonConfig = window.localStorage.getItem("localMsg");
jQuery(function () {
jQuery("#btnSaveInfo").click(function () {
var localUrl = jQuery("#txtLocalUrl").val();
var strRegex = /^(https|http|ftp|rtsp|mms):\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/;
if (jQuery("#txtSysName").val() == "") {
layer.msg('名称不能为空!', {
icon: 0,
time: 1000,
maxWidth: 200,
shade: 0.3
});
}
else if (jQuery("txtSysName").val() != "" && strRegex.test(localUrl)) {
if (jsonConfig == null) {
jsonConfig = [{ name: jQuery("#txtSysName").val(), localUrlAdd: jQuery("#txtLocalUrl").val()}];
jsonConfig = JSON.stringify(jsonConfig);
} else {
var str = { name: jQuery("#txtSysName").val(), localUrlAdd: jQuery("#txtLocalUrl").val() };
jsonConfig = eval(jsonConfig);
jsonConfig.push(str);
jsonConfig = JSON.stringify(jsonConfig);
}
window.localStorage.setItem("localMsg", jsonConfig);
layer.msg('配置成功!', {