66.设置为主页 function makeHome(){ netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite"); navigator.preference("browser.startup.homepage", location.href); }//
67.设置为收藏 function addFav(){ if(ie) window.external.AddFavorite(location.href,'WWW.OGRISH.COM : GROTESQUE MOVIES AND PICTURES'); if(ns) alert("Thanks for the bookmark!/n/nNetscape users click OK then press CTRL-D"); }//
68.判断cookie是否可用 navigator.cookieEnabled;//
69.显示有模式的有页面的弹出窗口 function setbgcolor_onclick() { var color = showModalDialog("/mailpage/compose/colorsel.html",0,"help=0"); if (color != null) { document.compose.bgcolor.value = color; } }//
70.截取小数点后两位 var a=3454545.4454545; alert(a.toFixed(2));//
97.获得本机的文件 var fso = new ActiveXObject("Scripting.FileSystemObject"); var f1 = fso.GetFile("C://bsitcdata//ejbhome.xml"); alert("File last modified: " + f1.DateLastModified); //
147. pasta 是有四个参数的构造器,定义对象。 function pasta(grain, width, shape, hasEgg) { // 是用什么粮食做的? this.grain = grain;
// 多宽?(数值) this.width = width;
// 横截面形状?(字符串) this.shape = shape;
// 是否加蛋黄?(boolean) this.hasEgg = hasEgg;
//定义方法 this.toString=aa; } function aa() {
} //定义了对象构造器后,用 new 运算符创建对象实例。 var spaghetti = new pasta("wheat", 0.2, "circle", true); var linguine = new pasta("wheat", 0.3, "oval", true); //补充定义属性,spaghetti和linguine都将自动获得新的属性 pasta.prototype.foodgroup = "carbohydrates";
148.打印出错误原因 try { x = y // 产生错误。 } catch(e) { document.write(e.description) //打印 "'y' is undefined". }//
149.生成Excel文件并保存 var ExcelSheet; ExcelApp = new ActiveXObject("Excel.Application"); ExcelSheet = new ActiveXObject("Excel.Sheet"); //本代码启动创建对象的应用程序(在这种情况下,Microsoft Excel 工作表)。一旦对象被创建,就可以用定义的对