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 工作表)。一旦對象被創建,就可以用定義的對