ITeye博客

js

共 15 篇文章

ueditor编辑器图片上传路径问题

第一部:修改jsp/config.json文件 访问前缀:#basePath# pathFormat:uploads前面添加“/”斜杠 /* 前后端通信相关的配置,注释只允许使用多行方式 */ { /* 上传图片配置项 */ "imageActionName": "uploadimage", /* 执行上传图片的action名称 */ "imageFieldName": "upfile", /* 提交的图片表单名称 */ "imageMaxSize": 2048000, /* 上传大小限制,单位B */ "imageAllowFiles": [".png", ".jpg", ".jpeg",…

2015-04-02 13:24 · jquery · js

Javascript 类与静态类的实现2

/***定义静态类***/ var StaticClass = (function(){ var Return = { Property: "Test Static Property", //公有属性 Method: function(){ //公有方法 alert(_Field); //调用私用字段 privateMethod(); //调用私用方法 } }; //定义返回的公有对象 var _Field = "Test Static Field"; //私有字段 var privateMethod = function(){ //私有方法 alert(Return.Property); …

2014-08-19 16:47 · jquery · js

Javascript 类与静态类的实现1

首先说说类,在一个类里我们会有以下的几个特征: 1. 公有方法 2. 私有方法 3. 属性 4. 私有变量 5. 析构函数 我们直接看一个例子: /***定义类***/ var Class = function(){ var _self = this;//把本身引用负值到一变量上 var _Field = "Test Field"; //私有字段 var privateMethod = function(){ //私有方法 alert(_self.Property); //调用属性 } this.Property = "Test Property"; //公有属性 this.Method =…

2014-08-19 16:45 · jquery · js

JS实现类拟JAVA中MAP对像的功能

/* name: Map.js author: WindDC date: 2006-10-27 content: 本程序用JS实现类拟JAVA中MAP对像的功能 */ function Node(key,value){//键值对对象 this.key=key; this.value=value; } function Map(){//Map类 this.nodes=new Array(); } Map.prototype.put=function(key,value){//往容器中加入一个键值对 for(var i=0;i<this.nodes.length;i++) if(this.nod…

2014-08-19 16:34 · jquery · js

jQuery 多功能无缝滚动插件

/*** @description 基于 jQuery 的多功能无缝滚动插件 @params auto: true # 是否自动滚动 interval: 3000 # 间隔时间(毫秒) direction: 'forward' # 向前 - forward / 向后 - backward speed: 500 # 移动速度(毫秒) showNum: 1 # 显示个数 stepLen: 1 # 每次滚动步长 type: 'horizontal' # 水平滚动 - horizontal / 垂直滚动 - vertical prevElement: null # 上一组按钮元素 prevBefor…

2014-08-05 13:00 · jquery · js

表情替换

/** * 表情替换 * * make by Administrator on 2014-7-21 上午11:53:15 * @param content * @return */ public static String replaceEmoticon(String content){ String basePath = SystemPropertyGetUtil.getResource("config").getString("system.url.base"); Pattern pattern = Pattern.compile(":([0-9]+):"); String replac…

2014-07-21 13:28 · java · js

textarea光标处插入内容,兼容IE、方法、chrome,可模拟表情

/** * tId 文本域Id * tag 插入内容 */ ffunction addEmoticon(tId,tag) { var txtarea = document.getElementById(tId); //IE if(document.selection) { var theSelection = document.selection.createRange().text; if(!theSelection) { theSelection=tag} txtarea.focus(); if(theSelection.charAt(theSelection.length - 1) =…

2014-07-17 18:07 · js

非常好的在网页中显示pdf的方法

参考: http://www.pdfobject.com/ <script type="text/javascript" src="scripts/pdfobject/pdfobject.js"></script> <script type="text/javascript"> window.onload = function (){ var success = new PDFObject({ url: "pdf/CGVET22-08-2011V2P.pdf" ,pdfOpenParams: { scrollbars: '0', toolbar: '0', statusbar: '0'}})…

2014-05-27 16:07 · js

兼容ie和火狐(firefox)的window.showModalDialog

一.计算Dialog居中位置。 function CalcShowModalDialogLocation(dialogWidth, dialogHeight) { var iWidth = dialogWidth; var iHeight = dialogHeight; var iTop = (window.screen.availHeight - 20 - iHeight) / 2; var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; return 'dialogWidth:' + iWidth + 'px;dialogHei…

2014-05-15 00:24 · js

复选框中 单选框 下拉

复选框 $("#id").is(":checked") 复选框选中 $("[name = field010]:checkbox").attr("checked", '${lcdy.field010}'); radio选中 $("input[name=test][value=34]").attr("checked",true);//value=34的radio被选中 $("input[id=testid][value=34]").attr("checked",true);//value=34的radio被选中 $('input:radio[name="field007"]').attr("ch…

2013-12-22 15:35 · jquery · js

jquery、js调用iframe父窗口与子窗口元素的方法

$("iframe").contents().find("body").append("I'm in an iframe!"); $(window.frames["iframe1"].document).find("input[@type='text']").attr("size","30px"); $("#iframe1").contents().find("#d1").css('color','red'); $(window.frames["iframe1"].document).find("input[@name='t1']").css({background:"#369"}); $(…

2013-11-06 16:15 · js

关于JS中的constructor与prototype

在学习JS的面向对象过程中,一直对constructor与prototype感到很迷惑,看了一些博客与书籍,觉得自己弄明白了,现在记录如下: 我们都知道,在JS中有一个function的东西。一般人们叫它函数。比如下面的代码 js代码: [javascript] view plain copy function Person(name) { alert(name); } Person('js');//js 上面的代码中,Person的表现的确跟一般的函数没有什么区别,接着看下面的代码 [javascript] view plain copy function Person(name) { t…

2013-10-29 14:56 · js

js数组的操作

1、数组的创建 1 var arrayObj = new Array(); //创建一个数组 2 3 var arrayObj = new Array([size]); //创建一个数组并指定长度,注意不是上限,是长度 4 5 var arrayObj = new Array([element0[, element1[, ...[, elementN]]]]); //创建一个数组并赋值 要说明的是,虽然第二种方法创建数组指定了长度,但实际上所有情况下数组都是变长的,也就是说即使指定了长度为5,仍然可以将元素存储在规定长度以外的,注意:这时长度会随之改变。 2、数组的元素的访问 1 var t…

2013-10-29 14:54 · js

100个直接可以拿来用的JavaScript实用功能

1、原生JavaScript实现字符串长度截取 function cutstr(str, len) { var temp; var icount = 0; var patrn = /[^\x00-\xff]/; var strre = ""; for (var i = 0; i < str.length; i++) { if (icount < len - 1) { temp = str.substr(i, 1); if (patrn.exec(temp) == null) { icount = icount + 1 } else { icount = icount + 2 } strre …

2013-09-13 09:43 · js

js 工具

1、js日期格式化: 使用方式:new Date(v).format('yyyy-MM-dd hh:mm'); Date.prototype.format = function(format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.getSeconds(), //second "q+": Math.floor((this.getMon…

2013-04-17 15:26 · jquery · js