js技巧收集(200多个)
op.value = document.all.all_items[i].value;//
159.判定一个窗口是否已经打开,假如已经打开,则关闭之
var a;
if(a)
a.close();
else
a=window.open('','','');//
160.动态创建一个标签
newElem = document.createElement("DIV");
newElem.id = "hint_layer";
document.body.appendChild(newElem);
document.all.hint_layer.innerText="guoguo";//
161.标题栏
document.title// 织梦内容管理系统
162.背景图片
<body style="BACKGROUND-ATTACHMENT: fixed" background="img/bgfix.gif" ></body>//背景图片不动
<STYLE TYPE="text/css">
<!--
BODY {background-image:img/bgchild.jpg;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;}
-->
</STYLE>//背景图片居中
本文来自织梦
163.设置透明效果
document.form.xxx.filters.alpha.opacity=0~100// 织梦好,好织梦
164.定义方法
var dragapproved=false;
document.onmouseup=new Function("dragapproved=false");//
165.将数字转化为人民币大写形式
function convertCurrency(currencyDigits) {
// Constants:
var MAXIMUM_NUMBER = 99999999999.99;
// Predefine the radix characters and currency symbols for output:
var CN_ZERO = "零";
var CN_ONE = "壹";
var CN_TWO = "贰";
var CN_THREE = "叁";
var CN_FOUR = "肆";
var CN_FIVE = "伍";
var CN_SIX = "陆";
var CN_SEVEN = "柒";
var CN_EIGHT = "捌";
var CN_NINE = "玖";
var CN_TEN = "拾";
var CN_HUNDRED = "佰";
var CN_THOUSAND = "仟";
var CN_TEN_THOUSAND = "万";
var CN_HUNDRED_MILLION = "亿";
var CN_SYMBOL = "人民币";
var CN_DOLLAR = "元";
var CN_TEN_CENT = "角";
var CN_CENT = "分";
var CN_INTEGER = "整";
// Variables:
var integral; // Represent integral part of digit number.
var decimal; // Represent decimal part of digit number.
var outputCharacters; // The output result.
var parts;
var digits, radices, bigRadices, decimals;
var zeroCount;
var i, p, d;
var quotient, modulus;
// Validate input string:
currencyDigits = currencyDigits.toString();
if (currencyDigits == "") {
alert("Empty input!");
return "";
}
if (currencyDigits.match(/[^,.\d]/) != null) {
alert("Invalid characters in the input string!");
return "";
}
if ((currencyDigits).match(/^((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d (.\d )?))$/) == null) {
alert("Illegal format of digit number!");
return "";
}
// Normalize the format of input digits:
currencyDigits = currencyDigits.replace(/,/g, ""); // Remove comma delimiters.
currencyDigits = currencyDigits.replace(/^0 /, ""); // Trim zeros at the beginning.
// Assert the number is not greater than the maximum number.
if (Number(currencyDigits) > MAXIMUM_NUMBER) {
alert("Too large a number to convert!");
return "";
}
// http://www.knowsky.com/ Process the coversion from currency digits to characters: 内容来自dedecms
// Separate integral and decimal parts before processing coversion:
parts = currencyDigits.split(".");
if (parts.length > 1) {
文章评论
共有位Admini5网友发表了评论 查看完整内容