} catch(java.lang.Exception ex) { ex.printStackTrace(); } }// 63.最小化窗口 window.blur()//
64.文档的路径 document.URL//
65.定时执行某段程序 setTimeout("change_color()",600); 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));//
71.禁止选择页面上的文字来拷贝 <script> function noEffect() { with (event) { returnValue = false; cancelBubble = true; } return; } </script> <body onselectstart="noEffect()" oncontextmenu="noEffect()">//
72.屏蔽右键菜单 oncontextmenu="event.returnValue = false"// 73.事件禁止起泡 event.cancelBubble = true// 74.禁止在输入框打开输入法 <input style="ime-mode: disabled">// 75.屏蔽汉字和空格 <input name="txt"><input type="submit" onClick="alert(!/[^ -}]|\s/.test(txt.value))">// 76.用javascript判断文件是否存在 function Exists(filespec) { if (filespec) { var fso; fso = new ActiveXObject("Scripting.FileSystemObject"); alert(fso.FileExists(filespec)); } } 选择图片 <input type=file name=f1><p> <input type="submit" onClick="Exists(f1.value)">// 77.获得当前的文本框选中的文字 <input onmouseup="alert(document.selection.createRange().text)" value=123>// 78.跳转至目标页面,同时不可返回 <a href="javascript:location.replace('http://www.sohu.com/')">sohu.com</a>// 79.获得当前的行是表格的第几行 <script> function getrow(obj) { if(event.srcElement.tagName=="TD"){ curRow=event.srcElement.parentElement; alert("这是第"+(curRow.rowIndex+1)+"行"); |