ITeye博客

javascript

共 5 篇文章

解决IE下PNG图片透明的问题

function correctPNG() { for(var i=0; i<document.images.length; i++) { var img = document.images[i]; var imgName = img.src.toUpperCase(); if (imgName.substring(imgName.length-3, imgName.length) == "PNG") { var imgID = (img.id) ? "id='" + img.id + "' " : ""; var imgClass = (img.className) ? "class='"…

2012-11-30 15:35 · javascript · CSS

ExtJs 2.0 通过Ext.form.BasicForm提交时,要注意的细节!

当form表单不是通过Ext自带的组件构成,而是由Html构成: <DIV ID="FORM_ID"> <FORM ID="ADD"> .... </FORM> </DIV> new Ext.Panel({ .... contentEl:'FORM_ID', .... buttons:[ {text:'保存',handler:add}, {text:'返回',handler:function(){ window.history.go(-1); }} ] }); function add () { var f = Ext.form.BasicForm('ADD',{ method:'post'…

2012-09-03 22:28 · javascript

FCK-API

利用Javascript取和设FCKeditor值也是非常容易的,如下: // 获取编辑器中HTML内容 function getEditorHTMLContents(EditorName) { var oEditor = FCKeditorAPI.GetInstance(EditorName); return(oEditor.GetXHTML(true)); } // 获取编辑器中文字内容 function getEditorTextContents(EditorName) { var oEditor = FCKeditorAPI.GetInstance(EditorName); retu…

2012-08-30 17:46 · javascript

JS获取中文字符的字节数

String.prototype.getBytes = function() { var cArr = this.match(/[^\x00-\xff]/ig); return this.length + (cArr == null ? 0 : cArr.length); } function CheckForm(str){ if(str.value.getBytes() > 64){ alert("字符超过64个字符"); return false; } return true; } getBytes用正则表达式来判断字符串中包含汉字的个数,包含的汉字都放到数组cArr中,这样cArr的长…

2012-08-10 13:34 · javascript

常用文本框输入限制代码

代码示例: onkeyup="value=value.replace(/[^a-zA-Z]/g,'')" 解释: replace(/[^a-zA-Z]/g,'')" 其中有 ^ 为逻辑词“非”,然后后面跟着a-zA-Z指的是英文字母大小写范围,“/g”表示全局替换,用后面的''中的字符,当前是空! 此句代码的含义为:在文本框中只能输入大写或小写字母,如果不是,则自动删除。 按键抬起来时验证 实际用法: <input onkeyup="value=value.replace(/[^a-zA-Z]/g,'')" ……………… 实例: 只能输入英文字母 onkeyup="value=value.r…

2012-07-23 14:28 · javascript