JavaScriptÖ®±£ÁôСÊýµãºóÖ¸¶¨Î»Êý
ÔÚ¿ª·¢¹ý³ÌÖо³£Óöµ½Òªµ÷ÕûСÊýµÄ¸ñʽ£¬Èç±£ÁôСÊýµãºóÁ½Î»µÈµÈ¡£·½·¨Ò²ÆÄΪ³£¼û£¬±¸ÍüÈçÏ¡£
µÚÒ»ÖÖ£¬ÀûÓÃmath.round
var original=28.453
1) //round "original" to two decimals
var result=Math.round(original*100)/100; //returns 28.45
2) // round "original" to 1 decimal
var result=Math.round(original*10)/10; //returns 28.5
µÚ¶þÖÖ£¬js1.5ÒÔÉÏ¿ÉÒÔÀûÓÃtoFixed(x) £¬¿ÉÖ¸¶¨Êý×Ö½ØÈ¡Ð¡Êýµãºó xλ
3) //round "original" to two decimals
var result=original.toFixed(2); //returns 28.45
4) // round "original" to 1 decimal
var result=original.toFixed(1); //returns 28.5
ÒÔÉÏÁ½ÖÖ·½·¨×îͨÓ㬵«È´ÎÞ·¨Âú×ãÄ³Ð©ÌØÊâÒªÇ󣬱ÈÈç±£ÁôСÊýµãºóÁ½Î»£¬Èç¹û²»ÂúÁ½Î»£¬²»ÂúÁ½Î»Ôò²¹Áã¡£´Ëʱ¾ÍÓÐÁ˵ÚÈýÖÖ·½·¨¡£
µÚÈýÖÖ£¬×ª»»º¯Êý£¬Õâ¶Î´úÂëÀ´Ô´ÓÚ¹úÍâÒ»¸öÂÛ̳¡£
function roundNumber(number,decimals) {
var newString;// The new rounded number
decimals = Number(decimals);
if (decimals < 1) {
newString = (Math.round(number)).toString();
} else {
var numString = number.toString();
if (numString.lastIndexOf(".") == -1) {// If there is no decimal point
numString += ".";// give it one at the end
}
var cutoff = numString.lastIndexOf(".") + decimals;// The point at which to truncate the number
var d1 = Number(numString.substring(cutoff,cutoff+1));// The value of the last decimal place that we'll end up with
var d2 = Number(numString.substring(cutoff+1,cutoff+2));// The next decimal, after the last one we want
if (d2 >= 5) {// Do we need to round up at all? If not, the string will just be truncated
if (d1 == 9 && cutoff > 0) {// If the last digit is 9, find a new cutoff point
while (cutoff > 0 && (d1 == 9 || isNaN(d1))) {
if (d1 != ".") {
cutoff -= 1;
d1 = Number(numString.substring(cutoff,cutoff+1));
} else {
cutoff -= 1;
}
}
}
d1 += 1;
}
if (d1 == 10) {
numString = numString.substring(0, numString.lastIndexOf("."));
var roundedNu
Ïà¹ØÎĵµ£º
scrollHeight: »ñÈ¡¶ÔÏóµÄ¹ö¶¯¸ß¶È¡£
scrollLeft:ÉèÖûò»ñȡλÓÚ¶ÔÏó×ó±ß½çºÍ´°¿ÚÖÐĿǰ¿É¼ûÄÚÈݵÄ×î×ó¶ËÖ®¼äµÄ¾àÀë
scrollTop:ÉèÖûò»ñȡλÓÚ¶ÔÏó×î¶¥¶ËºÍ´°¿ÚÖпɼûÄÚÈݵÄ×î¶¥¶ËÖ®¼äµÄ¾àÀë
scrollWidth:»ñÈ¡¶ÔÏóµÄ¹ö¶¯¿í¶È
offsetHeight:»ñÈ¡¶ÔÏóÏà¶ÔÓÚ°æÃæ»òÓɸ¸×ø±ê offsetParent ÊôÐÔÖ¸¶¨µÄ¸¸×ø±êµÄ¸ß¶È
offsetL ......
1¡¢»ìºÏµÄ¹¹Ô캯Êý/ÔÐÍ·½·¨
Óù¹Ô캯Êý¶¨Òå¶ÔÏóµÄËùÓзǺ¯ÊýÊôÐÔ£¬ÓÃÔÐÍ·½Ê½¶¨Òå¶ÔÏóµÄº¯ÊýÊôÐÔ(·½·¨)£¬½á¹ûËùÓк¯Êý¶¼Ö»´´½¨Ò»´Î£¬¶øÃ¿¸ö¶ÔÏó¶¼¾ßÓÐ×Ô¼ºµÄ¶ÔÏóÊôÐÔʵÀý¡£
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional. ......
JavaScript
ת×Ô£º http://www.disandu.com/?p=603
============================================================================
1 ´¦ÀíXSLT µ÷Óôø²ÎÊýµÄXSLTÄ£°åµÄ·½·¨ Ïê¼û 23Ìõ
<html>
<body>
  ......
<script language="JavaScript">
<!--
calendar = new Date();
day = calendar.getDay();
month = calendar.getMonth();
date = calendar.getDate();
year = calendar.getYear();
if (year< 100) year = 1900 + year;
cent = parseInt(year/100);
g = year % 19;
k = parseInt((cent - 17)/25);
i = ......
ÔÖ·£ºhttp://www.dreamdu.com/blog/2008/10/19/json_in_javascript/
JavaScriptÖеÄJSON
×÷ÕߣºDouglas Crockford
ÔÎÄÍøÖ·£ºhttp://www.json.org/js.html
ÒëÕߣº¿É°®µÄºï×Ó
JavaScriptÕâÖÖ±à³ÌÓïÑÔÊ×ÒªµÄÄ¿µÄÊÇΪNetscape NavigatorÌṩһÖÖÒ³Ãæ½Å±¾ÓïÑÔ¡£ËüÈÔ±»ÆÕ±éµÄÈÏΪÊÇJavaµÄÒ»¸ö×Ó¼¯£¬µ«ÊÂʵ²¢·ÇÈç´Ë¡£ËüÊ ......