150.根据标签获得一组对象 var coll = document.all.tags("DIV"); if (coll!=null) { for (i=0; i<coll.length; i++) ... }// 151.实现打印预览及打印 <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT> <input type=button value=打印预览 onclick="wb.execwb(7,1)"> <input type=button onClick=document.all.wb.ExecWB(6,1) value="打印">// 152.不通过form,直接通过名字引用对象 <INPUT TYPE="text" NAME="gg" value=aaaaa> <SCRIPT LANGUAGE="JavaScript"> <!-- alert(document.all.gg.value) //--> </SCRIPT>// 153.使鼠标滚轮失效 function document.onmousewheel() { return false; }// 154.创建弹出窗口 <SCRIPT LANGUAGE="JScript"> var oPopup = window.createPopup(); var oPopupBody = oPopup.document.body; oPopupBody.innerHTML = "Display some <B>HTML</B> here."; oPopup.show(100, 100, 200, 50, document.body); </SCRIPT>// 155.取得鼠标所在处的对象 var obj = document.elementFromPoint(event.x,event.y);// 156.获得左边的对象 <INPUT TYPE="text" NAME="gg"><INPUT TYPE="text" NAME="bb" onclick="this.previousSibling.value='guoguo'">// 157.定位鼠标 document.all.hint_layer.style.left = event.x+document.body.scrollLeft+10; document.all.hint_layer.style.top = event.y+document.body.scrollTop+10;// 158.向下拉框指定位置添加项目 var op = document.createElement("OPTION"); document.all.selected_items.children(index).insertAdjacentElement("BeforeBegin",op); op.text = document.all.all_items[i].text; 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: // Separate integral and decimal parts before processing coversion: parts = currencyDigits.split("."); if (parts.length > 1) { integral = parts[0]; decimal = parts[1]; // Cut down redundant decimal digits that are after the second. decimal = decimal.substr(0, 2); } else { integral = parts[0]; decimal = ""; } // Prepare the characters corresponding to the digits: digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, |