122d12/ if a null alert输入的参数不是时间格式 return false if a1gt24 a3gt60 a4gt60 alertquot时间格式不对quot 第 3 页 return false return truefunction isCorrectDatestr //2003-12-05 var r str.match/d14-/d122d12/ ifrnullreturn false var d new Dater1 r3-1 r4 return d.getFullYearr1ampampd.getMonth1r3ampampd.getDater4function isCorrectDateTimestr //2003-12-05 13:04:06 var reg /d14-/d122d12 d12:d12:d12/ var r str.matchreg ifrnullreturn false var d new Dater1 r3-1r4r5r6r7 returnd.getFullYearr1ampampd.getMonth1r3ampampd.getDater4ampampd.getHoursr5ampampd.getMinutesr6ampampd.getSecondsr728.去掉前后空白this.value.replace/ss/g29.操作selectifobjselect.selectedIndex gt -1 alertselected//是否有选中objselect.optionsobjselect.selectedIndex null//删除被选中的项objselect.optionsobjselect.length new Optionquottextquotquotvaluequot//增加项objselect.optionsobjselect.selectedIndex.text//得到所选择项的文本objselect.optionsobjselect.selectedIndex.value//得到所选择项的值document.getElementByidquotelquot.tabIndex 1//焦点顺序30.添加到收藏夹:window.external.AddFavoritehttp://www.
java.com31.模态对话框window.showModelessDialog方法用来创建一个显示HTML内容的非模态对话框。
window.showModalDialog方法用来创建一个显示HTML内容的模态对话框,由于是对话框,因此它并没有一般用window.open打开的窗口的所有属性。
只是FireFox浏览器中不支持showmodaldialog,用window.open。
在Firefox下window.open的参数中sFeature多了一些功能设定要让FireFox下开启的窗口跟IE的showModalDialog一样的话只要在sFeatures中加个modalyes就可以了也许可能是出于安全考虑modalyes 打开的并不是模式窗口。
ltinput typequotbuttonquot valuequot打开对话框quot onclickquotshowDialogquot/gt ltSCRIPT LANGUAGEquotJavaScriptquotgt lt-- function showDialogurl ifdocument.all//IE featurequotdialogWidth:300pxdialogHeight:200pxstatus:nohelp:noquot window.showModalDialogurlnullfeature else //modelessDialog可以将modal换成dialogyes feature quotwidth300height200menubarnotoolbarnolocationnoquot featurequotscrollbarsnostatusnomodalyesquot window.openurlnullfeature //--gtlt/SCRIPTgt32.屏蔽打印按钮ltstyle typequottext/cssquotgtlt--media print .disp display: none --gtlt/stylegt33.动态改变CSSfunction changeLinkCssurl var link_cssdocument.getElementsByTagNamelink 第 4 页 forvar i0iltlink_css.lengthi iflink_cssi.rel.toLowerCase stylesheet link_cssi.href url 34.置下一元素焦点function setNextFocus var srcObj event.srcElement var len document.all.length var idx -1 forvar i0 iltlen i var curObj document.alli ifcurObj srcObj idx i break ifidx -1 ampamp idx lt len-1 forvar jidx1 jltlenj ifcheckTagsdocument.allj document.allj.focus return function checkTagsobj ifobj.readOnly true obj.disabled true return false var tag_name obj.tagName var el_tags selectinputtextarea forvar i0 iltel_tags.length i ifel_tagsi tag_name.toLowerCase return true return false35.获得当前目录路径function getCurrentDirectoryvar locHref location.hrefvar locArray locHref.splitquot/quot/这里测试locArray效果 forx in locArray document.writequotlocArrayquot document.writexquot: quot document.writelocArrayxquotltbr /gtquot / delete locArraylocArray.length-1 var dirTxt locArray.joinquot/quot return dirTxtdocument.writegetCurrentDirectory36.清空file域innerHTML 设置或获取位于对象起始和结束标签内的 HTMLouterHTML 设置或获取对象及其内容的 HTML 形式innerText 设置或获取位于对象起始和结束标签内的文本outerText 设置包括标签或获取不包括标签对象的文本function Clean var objdocument.getElementByIdquotUpFilequot obj.outerHTMLobj.outerHTML37.js之arguments 使用JavaScript函数内置的arguments可以遍历所有传入的参数。
arguments有个callee属性,可以调用arguments自身所在的函数。
也就是说,可以通过这个属性递归调用函数自身。
function sum var total 0 forvar i 0 i lt arguments.length i total argumentsi 第 5 页 alerttotalsum1 2sum1 2 3function sumn ifn lt 1 return 1 return n arguments.calleen - 1 // 递归调用自身alertsum10038.document.execCommandltinput typebutton value剪切 onclickdocument.execCommandCutgtltinput typebutton value拷贝 onclickdocument.execCommandCopygtltinput typebutton value粘贴 onclickdocument.execCommandPastegtltinput typebutton value撤消 onclickdocument.execCommandUndogtltinput typebutton value重做 onclickdocument.execCommandRedo idbutton2 namebutton2gtltinputgtltinput typebutton value删除 onclickdocument.execCommandDeletegtltinput typebutton value黑体 onclickdocument.execCommandBoldgtltinput typebutton value斜体 onclickdocument.execCommandItalicgtltinput typebutton value下划线 onclickdocument.execCommandUnderlinegtltinput typebutton value停止 onclickdocument.execCommandstopgtltinput typebutton value保存 onclickdocument.execCommandSaveAsgtltinput typebutton value另存为 onclickdocument.execCommandSaveasfalsec:test.htmgtltinput typebutton value字体 onclickdocument.execCommandFontNamefalsefngtltinput typebutton value字体大小 onclickdocument.execCommandFontSizefalsefsgtltinput typebutton value刷新 onclickdocument.execCommandrefreshfalse0gt- isNaN是测试是否为数值型 ,限制输入只能为数值如:1981.121,允许最多有一个小数点ltinput typequottextquot namequottextquot onkeyupquotifisNaNvalueexecCommandundoquot /gt IE6下默认不缓存背景图片,CSS里每次更改图片的位置时都会重新发起请求,用这个方法告诉IE6缓存背景图片。
try document.execCommandBackgroundImageCache false true catche 39.取消事件冒泡在 IE 的事件机制中,触发事件会从子元素向父元素逐级上传,就是说,如果子元素触发了单击事件,那么也会触发父元素的单击事件;event.cancelBubbletrue可以停止事件继续上传补充一点,Ie的事件传递是从下到上的:事件来源对象-gt上级对象-gt上上级对象-gt.....-gtbody-gtdocument-gtwindow40.禁止选择文字ltdiv unselectablequotonquot onselectstartquotreturn falsequot stylequot-moz-user-select:nonequot gt禁止选择unselectable为IE准备 , onselectstart为Chrome、Safari准备 -moz-user-select是FF的 lt/divgt41.js释放内存CollectGarbage是IE的一个特有属性用于释放内存的,使用方法嘛应该是将该变量或引用对象设置为null或delete,然后在进行释放动作,在做CollectGarbage前要必需清楚的两个必备条件:1一个对象在其生存的上下文环境之外,即会失效。
2一个全局的对象在没有被执用引用的情况下,即会失效。
System.gc function if System.isIeBrowser CollectGarbage setTimeoutquotCollectGarbagequot 1 42.QVOD播放器代码ltobject classidquotclsid:F3D0D36F-23F8-4682-A195-74C92B03D4AFquot widthquot500quot heightquot400quot idquotQvodPlayerquotnamequotQvodPlayerquot onErrorifwindow.confirm请您先安装QvodPlayer软件然后刷新本页才可以正常播放.window.openhttp://www.qvod.com/download.htmelseself.locationhttp://www.qvod.com/gt ltPARAM NAMEURL VALUE此处请替换成QVOD播放链接地址gt ltPARAM NAMEAutoplay VALUE1gtlt/objectgt43.图片旋转function imageTurnidfilter//水平:quotfliphquot与垂直:quotflipVquot var img document.getElementByIdid img.style.filter img.style.filter filter quotquot : filter 第 6 页44.设置一组css属性function setStyleobjcss forvar atr in css obj.styleatr cssatrvar head document.getElementByIdquotheadquotsetStyleheadwidth:quot200pxquotheight:quot70pxquotdisplay:quotblockquotvar head document.getElementByIdquotheadquothead.style.cssTextquotwidth:200pxheight:70pxdisplay:bolckquot45.滤镜RevealTrans duration转换的秒数,transition转换的类型) transition的取值为0-23。
代表24种过渡效果。
可以用在整个页面上,也可以用在页面的某一个物件上。
ltMETA http-equivPage-Exit’ CONTENTRevealTransDuration0.5Transition23gtltimg idquotimg1quot srcquotimg1.jpgquot widthquot300quot heightquot226quotstylequotfilter:revealTransTransition1Duration1.5quot /gt46.不用eval解析JSONfunction jsonDecodedata return new Functionquotreturn quot data 其他要想实现类似的eval的功能,一般都是在DOM中创建一个script节点,然后script.text data47、不提示关闭窗口function closeWindow window.openernull window.open_self window.close17:00浏览 262评论 0分类: js/css2009-03-12缩略显示javascript keyCode关键字: javascript keycode1.keycode 8 BackSpace BackSpace2.keycode 9 Tab Tab3.keycode 12 Clear4.keycode 13 Enter5.keycode 16 Shift_L6.keycode 17 Control_L7.keycode 18 Alt_L8.keycode 19 Pause9.keycode 20 Caps_Lock10.keycode 27 Escape Escape11.keycode 32 space space12.keycode 33 Prior13.keycode 34 Next14.keycode 35 End15.keycode 36 Home16.keycode 37 Left17.keycode 38 Up18.k.
上一篇:
【精品】C++程序书写规范
下一篇:
计算机网络毕业论文