??xml version="1.0" encoding="utf-8" standalone="yes"?> 专注于分享Java后端相关技术、老司机实战干货,不限于JVM、ƈ发、设计模式、性能优化、分布式&微服务、云原生、大数据相关主题?/span> Deserializes JavaScript Object Notation (JSON) text to produce a JavaScript value. Required. Valid JSON text. Optional. A function that filters and transforms the results. The deserialized object is traversed recursively, and the reviver function is called for each member of the object in post-order (every object is revived after all its members have been revived). For each member, the following occurs: If reviver returns a valid value, the member value is replaced with the value returned by reviver. If reviver returns what it received, the structure is not modified. If reviver returns null or undefined, the object member is deleted. The reviver argument is often used to transform JSON representation of International Organization for Standardization (ISO) date strings into Coordinated Universal Time (UTC) format Date objects. Exception Condition JavaScript parser errors The input text does not comply with JSON syntax. To correct the error, do one of the following: Modify the text argument to comply with JSON syntax. For more information, see the BNF syntax notation of JSON objects. Make sure that the text argument was serialized by a JSON-compliant implementation, such as, JSON.stringify. This example uses JSON.parse to deserialize JSON text into the contact object. This example uses JSON.parse to deserialize an ISO-formatted date string. The dateReviver function returns Date objects for members that are formatted like ISO date strings. Supported in the following document modes: Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information. Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards. Serializes a JavaScript value into JavaScript Object Notation (JSON) text. Required. A JavaScript value, usually an object or array, to be serialized. Optional. A function or array that filters and transforms the results. If replacer is a function, JSON.stringify calls the function, passing in the key and value of each member. The return value is serialized instead of the original value. If the function returns undefined, the member will be excluded from the serialization. The key for the root object is an empty string: "". If replacer is an array, only members with key values in the array will be serialized. The order of serialization is the same as the order of the keys in the array. Thereplacer array is ignored when the value argument is also an array. Optional. Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. If space is omitted, the return-value text is generated without any extra white space. If space is a number, the return-value text is indented with the specified number of white spaces at each level. If space is greater than 10, text is indented 10 spaces. If space is a non-empty string, such as '\t', the return-value text is indented with the characters in the string at each level. If space is a string that is longer than 10 characters, the first 10 characters are used. If the value that is being serialized has a toJSON method, the JSON.stringify function calls the toJSON method and uses the return value for serialization. If the return value of the toJSON method is undefined, the member will not be serialized. This enables an object to determine its own JSON representation. Values that do not have JSON representations, such as undefined, will not be serialized. In objects, they will be dropped. In arrays, they will be replaced with null. String values begin and end with a quotation mark. All Unicode characters may be enclosed in the quotation marks except for the characters that must be escaped by using a backslash. The following characters must be preceded by a backslash: Quotation mark (") Backslash (\) Backspace (b) Formfeed (f) Newline (n) Carriage return (r) Horizontal tab (t) Four-hexadecimal-digits (uhhhh) During the serialization process, if a toJSON method exists for the value argument, JSON.stringify first calls the toJSON method. If it does not exist, the original value is used. Next, if a replacer argument is provided, the value (original value or toJSON return-value) is replaced with the return-value of the replacer argument. Finally, white spaces are added to the value based on the optional space argument to generate the final serialized JSON text. This example uses JSON.stringify to serialize the contact object to JSON text. The memberfilter array is defined so that only the surname and phone members are serialized. The firstname member is omitted. This example uses JSON.stringify to serialize an array. The replaceToUpper function converts every string in the array to uppercase. This example uses the toJSON method to serialize string member values in uppercase. Supported in the following document modes: Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information. Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards. <script type="text/javascript"> $("#ddlProvince").empty(); //清空省䆾SELECT控g $.getJSON("/ajax/GetProvinceList", function(data) { } function GetCity() { $("#ddlCity").empty(); //清空城市SELECT控g function GetDistrict() { </script> 下面q段html代码是在struts2的下拉标{中加入了span标签Q在面装蝲的时候就让下拉框变成不可诅R?/p>
<body onload="init()"> <span id="id_select"> </body> 如下是js代码Q在initҎ中调用selectReadOnly让下拉框变成只读?/p>
/*Ҏ面上span的id讄select为只?/strong>/ function selectReadOnly(selectedId){ function init(){
Java爱好者社?/strong>
公众号内容简介:
希望x的你停下脚步Q定有所收获?/span>
以前的个人博客内容不好迁U,所以我打算Ҏ自己的多q经验,不断整理输出有h值的内容?br />目前公众号内Ҏ关于SpringCloudQ微服务框架Q、SkywalkingQAPM监控调用链)、JVMQGC分析、内存泄漏分析)、ƈ发编E?/span>相关原创实战文章已出炉?br />
最q刚开始已l有不少伙伴关注了Q期待能有幸搜烦到本博客的同学,可以扫码x一下,不胜感激?br />大家有Q何技术、职场、面试上的问题都可以与我交流?br />
方式一Q?/strong>扫码以下公众号二l码Q?/strong>
方式二:在微信上直接搜烦Q?nbsp;javatech_cbo
感谢各位伙伴的支持Q后l会在该公众号上输出大量的有价值的实战q货 Q期待与你一同进步与成长?br />
]]>JSON.parse(text [, reviver])
var jsontext = '{"firstname":"Jesper","surname":"Aaberg","phone":["555-0100","555-0120"]}'; var contact = JSON.parse(jsontext); var fullname = contact.surname + ", " + contact.firstname; // The value of fullname is "Aaberg, Jesper"
var jsontext = '{ "hiredate": "2008-01-01T12:00:00Z", "birthdate": "2008-12-25T12:00:00Z" }'; var dates = JSON.parse(jsontext, dateReviver); var string = dates.birthdate.toUTCString(); // The value of string is "Thu, 25 Dec 2008 12:00:00 UTC" function dateReviver(key, value) { var a; if (typeof value === 'string') { a = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); if (a) { return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], +a[5], +a[6])); } } return value; };
JSON.stringify(value [, replacer] [, space])
Order of Execution
var contact = new Object(); contact.firstname = "Jesper"; contact.surname = "Aaberg"; contact.phone = ["555-0100", "555-0120"]; var memberfilter = new Array(); memberfilter[0] = "surname"; memberfilter[1] = "phone"; var jsonText = JSON.stringify(contact, memberfilter, "\t"); /* The value of jsonText is: '{ "surname": "Aaberg", "phone": [ "555-0100", "555-0120" ] }' */
var continents = new Array(); continents[0] = "Europe"; continents[1] = "Asia"; continents[2] = "Australia"; continents[3] = "Antarctica"; continents[4] = "North America"; continents[5] = "South America"; continents[6] = "Africa"; var jsonText = JSON.stringify(continents, replaceToUpper); /* The value of jsonText is: '"EUROPE,ASIA,AUSTRALIA,ANTARCTICA,NORTH AMERICA,SOUTH AMERICA,AFRICA"' */ function replaceToUpper(key, value) { return value.toString().toUpperCase(); }
var contact = new Object(); contact.firstname = "Jesper"; contact.surname = "Aaberg"; contact.phone = ["555-0100", "555-0120"]; contact.toJSON = function(key) { var replacement = new Object(); for (var val in this) { if (typeof (this[val]) === 'string') replacement[val] = this[val].toUpperCase(); else replacement[val] = this[val] } return replacement; }; var jsonText = JSON.stringify(contact); /* The value of jsonText is: '{"firstname":"JESPER","surname":"AABERG","phone":["555-0100","555-0120"]}' */
]]>
ȝq不错的
$(document).ready(function() {
GetByJquery();
$("#ddlProvince").change(function() { GetCity() });
$("#ddlCity").change(function() { GetDistrict() });
});
function GetByJquery() {
$.each(data, function(i, item) {
$("<option></option>")
.val(item["ProvinceID"])
.text(item["ProvinceName"])
.appendTo($("#ddlProvince"));
});
GetCity();
});
var url ="/ajax/GetCityList/" + $("#ddlProvince").val();
$.getJSON(url, function(data) {
$.each(data, function(i, item) {
$("<option></option>")
.val(item["CityID"])
.text(item["CityName"])
.appendTo($("#ddlCity"));
});
GetDistrict();
});
}
$("#ddlDistrict").empty(); //清空市区SELECT控g
var url = "/ajax/GetDistrictList/" + $("#ddlCity").val();
$.getJSON(url, function(data) {
$.each(data, function(i, item) {
$("<option></option>")
.val(item["DistrictID"])
.text(item["DistrictName"])
.appendTo($("#ddlDistrict"));
});
});
}
]]>
return false;
if(this.substring(this.length-str.length)==str) return true;
else return false;
return true;
}
]]>
在项目开发过E中我们时常会碰到要讄下拉框ؓ只读QreadonlyQ,但是可惜的是select没有只读属性,所以需要在select外面包含一?span style="color: #ff0000">spanQ通过js来改变?/p>
<s:select name="sjdwmc" list="sjdxdwList" listKey="dxbh" listValue="dwmc" headerKey="" headerValue=""></s:select>
</span>
var obj = document.getElementById(selectedId);
obj.onmouseover = function(){
obj.setCapture();
}
obj.onmouseout = function(){
obj.releaseCapture();
}
obj.onfocus = function(){
obj.blur();
}
obj.onbeforeactivate = function(){
return false;
}
}
selectReadOnly("id_select");
}
]]>
<script language="JavaScript" type="text/javascript">
<!--
calendar = new Date(); //得到当前日期
day = calendar.getDay(); //当前多数?
month = calendar.getMonth(); //当前月䆾
date = calendar.getDate(); //当前星期
year = calendar.getYear(); //q䆾
if (year< 100) year = 1900 + year;
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
l = i - j;
emonth = 3 + parseInt((l + 40)/44);
edate = l + 28 - 31*parseInt((emonth/4));
emonth--;
var dayname = new Array ("星期?, "星期一", "星期?, "星期?, "星期?, "星期?, "星期?);
var monthname =
new Array ("1?,"2?,"3?,"4?,"5?,"6?,"7?,"8?,"9?,"10?,"11?,"12? );
document.write(year +"q?);
document.write(monthname[month]);
document.write(date + "?+" ");
document.write(dayname[day]);
//-->
</script>
js日期相关
var myDate = new Date();
myDate.getYear(); //获取当前q䆾(2?
myDate.getFullYear(); //获取完整的年?4?1970-????)
myDate.getMonth(); //获取当前月䆾(0-11,0代表1?
myDate.getDate(); //获取当前?1-31)
myDate.getDay(); //获取当前星期X(0-6,0代表星期?
myDate.getTime(); //获取当前旉(?970.1.1开始的毫秒?
myDate.getHours(); //获取当前时?0-23)
myDate.getMinutes(); //获取当前分钟?0-59)
myDate.getSeconds(); //获取当前U数(0-59)
myDate.getMilliseconds(); //获取当前毫秒?0-999)
myDate.toLocaleDateString(); //获取当前日期
var mytime=myDate.toLocaleTimeString(); //获取当前旉
myDate.toLocaleString( ); //获取日期与时?/ca>
<SCRIPT LANGUAGE="JavaScript">
<!--
var now= new Date();
var year=now.getYear();
var month=now.getMonth()+1;
var day=now.getDate();
var hour=now.getHours();
var minute=now.getMinutes();
var second=now.getSeconds();
alert(year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second);
-->
</SCRIPT>
now.getMilliseconds(); //获取当前毫秒?0-999)
基本介绍Q?br />
showModalDialog() (IE 4+ 支持)
showModelessDialog() (IE 5+ 支持)
window.showModalDialog() Ҏ用来创徏一个显CHTML内容的模态对话框?br />
window.showModelessDialog() Ҏ用来创徏一个显CHTML内容的非模态对话框?br />
使用ҎQ?br />
vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures])
vReturnValue = window.showModelessDialog(sURL [, vArguments] [,sFeatures])
参数说明Q?br />
sURL -- 必选参敎ͼcdQ字W串。用来指定对话框要显C的文档的URL?br />
vArguments -- 可选参敎ͼcdQ变体。用来向对话框传递参数。传递的参数cd不限Q包括数l等。对话框通过window.dialogArguments来取得传递进来的参数?br />
sFeatures -- 可选参敎ͼcdQ字W串。用来描q对话框的外观等信息Q可以用以下的一个或几个Q用分号“;”隔开?br />
----------------
1. dialogHeight: 对话框高度,不小?00px
2. dialogWidth: 对话框宽度?br />
3. dialogLeft: dq左的距R?br />
4. dialogTop: dq上的距R?br />
5. center: { yes | no | 1 | 0 } Q?nbsp; 是否居中Q默认yesQ但仍可以指定高度和宽度?br />
6. help: {yes | no | 1 | 0 }Q?nbsp; 是否昄帮助按钮Q默认yes?br />
7. resizable: {yes | no | 1 | 0 } [IE5+]Q?nbsp; 是否可被改变大小。默认no?br />
8. status: {yes | no | 1 | 0 } [IE5+]Q?nbsp; 是否昄状态栏。默认ؓyes[ Modeless]或no[Modal]?br />
9. scroll: { yes | no | 1 | 0 | on | off }Q是否显C滚动条。默认ؓyes?br />
下面几个属性是用在HTA中的Q在一般的|页中一般不使用?br />
10. dialogHide:{ yes | no | 1 | 0 | on | off }Q在打印或者打印预览时对话框是否隐藏。默认ؓno?br />
11. edge:{ sunken | raised }Q指明对话框的边框样式。默认ؓraised?br />
12. unadorned:{ yes | no | 1 | 0 | on | off }Q默认ؓno?br />
参数传递:
1. 要想对话框传递参敎ͼ是通过vArguments来进行传递的。类型不限制Q对于字W串cdQ最大ؓ4096个字W。也可以传递对象,例如Q?br />
-------------------------------
parent.htm
<script>
var obj = new Object();
obj.name="51js";
window.showModalDialog("modal.htm",obj,"dialogWidth=200px;dialogHeight=100px");
</script>
modal.htm
<script>
var obj = window.dialogArguments
alert("您传递的参数为:" + obj.name)
</script>
-------------------------------
2. 可以通过window.returnValue向打开对话框的H口q回信息Q当然也可以是对象。例如:
------------------------------
parent.htm
<script>
str =window.showModalDialog("modal.htm",,"dialogWidth=200px;dialogHeight=100px");
alert(str);
</script>
modal.htm
<script>
window.returnValue="http://homepage.yesky.com";