JavaScript
czjuttsw
Learning, staying up to date, and working on the latest and greatest in languages and APIs is what keeps me excited.
展开
-
JavaScript操作cookie的一个小小失误
最近在做一个基于SSH的网站。其中有一个登录模块,需要实现记住密码的功能。就是在输入用户名的时候,如果该用户的密码被记住过,则在输完用户名后(当焦点离开时自动填充密码)于是马上想到了Cookie技术。由于需要在页面中显示指定用户保存的密码,因此需要和JavaScript打交道。查阅了相关资料,发现了JavaScript也支持Cookie。核心内容是doc原创 2012-12-24 23:21:21 · 1378 阅读 · 0 评论 -
[html]自定义文件上传按钮
如果觉得文件上传按钮太难看,如果觉得上传按钮在各个浏览器上显示的效果不一致。我们可以自定义文件上传按钮。实现方案是将文件上传按钮的点击事件传递给其他按钮。.html ->文件上传.css ->#myFile { visibility: hidden; /* 隐藏 */}#myBtn { /* 在这里自定义你的原创 2014-04-01 17:48:48 · 11504 阅读 · 0 评论 -
JavaScript中的构造函数
JavaScript和Java一样,都是面向对象语言的。但是不同的是,JavaScript没有class的概念。因此,JavaScript的构造函数和Java等面向对象语言的构造函数会有所不同。在Java中,一个普通的构造函数可以是这样的:public class Person { private String name; private int age; private St原创 2013-11-01 16:38:37 · 1221 阅读 · 0 评论 -
JavaScript自调用匿名函数
Self-Invoking Anonymous Function,即自调用匿名函数。顾名思义,该函数没有名称,不同的是,该函数定义后立即被调用。该函数的作用是在应用中初始化或做一次性工作。普通匿名函数:function () { alert('hello');}自调用无参匿名函数:(function(){ alert('hello,self-invokin原创 2013-09-01 14:02:51 · 4399 阅读 · 0 评论 -
grumble.js
grumble.js是一个jQuery插件。它提供了气泡提示框功能。我们可以自定义气泡框的角度,大小,内容,以及回调方法等。用法很简单:$('#grumble1').grumble( { text: '', angle: 200, distance: 3, showAfter: 1000, hideAfter: 2000 });text 表示气泡框内原创 2013-08-06 20:42:35 · 1974 阅读 · 1 评论 -
有了HTML5,我们无需再使用embed标签播放音乐或者视频了
在HTML5中提供了2个重要的标签,一个是audio,还有一个是video。 Playing songs Sorry,your browser doesn't support>原创 2013-02-28 22:30:17 · 2352 阅读 · 1 评论 -
防止浏览器读取缓存的一个老方法
有时候我们利用WebService获取数据的时候,访问它的URL几乎是不变的,但是内容却随着服务器的更新而不同,可是问题是浏览器考虑到性能的原因,对重复的URL操作,如果有缓存,则会将旧的信息返回给浏览器,而不是重新到服务器上去请求信息。解决该问题的一个简单的办法是在URL尾部添加一个随机字符串,最常用的是加上当前日期。比如JS:var url = "www.webservices.c原创 2013-02-28 10:36:20 · 3298 阅读 · 1 评论 -
XMLHttpRequest VS. JSONP
当我们利用XMLHttpRequest对象从本地服务器获取数据时是可以的。 假设我们使用的数据格式为JSON(JavaScript Object Notation),并且我们在本地服务器上部署了一个样本数据data.json:{"completed_in":0.044,"max_id":306750251744784385,"max_id_str":"3067502517447原创 2013-02-27 21:54:05 · 3414 阅读 · 0 评论 -
JavaScript实现简单的时钟
JS实现简单的时钟 function displayTime() { document.getElementById("time").innerHTML = new Date().toTimeString(); } setInterval(displayTime,1000); // 每隔1秒钟调用displayTime函原创 2013-03-07 12:24:32 · 3430 阅读 · 0 评论