Firefox下,表单元素的autocomplete属性

25日的扯淡里,碰巧发现了autocomplete的作用。今天看见realazy兄遇到按扭状态未还原问题,通过js来重置。其实用autocomplete就可以轻松解决:

<input name="submitBtn" autocomplete="off" type="submit" value="提交" />

这样,后退或刷新页面时,Firefox就不会自动记忆表单状态了。

演示页面:firefox_autocomplete_test.php

详细资料:How to Turn Off Form Autocompletion

Tags: , ,

Twitter Tool Patched Version

Twitter Tool是世界上最流行的微博客Twitter在世界上最流行的博客WordPress上的一款插件:

This plugin creates an integration between your WordPress blog and your Twitter account. Pull your tweets into your blog and create new tweets on blog posts and from within WordPress.

目前稳定版本1.2b1对时区的处理上存在问题,比如对中国用户来说,存在8小时偏差。花了点时间从网上搜索到了解决方案,同时参考LoudTwitter的输出,给daily digest的每条tweet加上了时间戳,效果可以参考这里。具体样式取决于WordPress皮肤,自己在style.css里调整下吧。

下载:twitter-tools.zip (17.7 KB)

Tags: , ,

去除警告提示“无法验证发行者,确定要运行此软件吗”

运行网络映射盘上的程序时,总是弹出“无法验证发行者,确定要运行此软件吗” 或者 ”Security warning: The publisher could not be verified. Are you sure…?“ 这个对话框很恼人。可以通过下面的方法解决:

运行 gpedit.msc, 打开组策略
用户配置 -› 管理模板 -› Windows 组件 -› 附件管理器
启用“中等危险文件类型的包含列表”,在“指定中等危险扩展名”中填入:.cmd; .bat; .exe; .js

确定后,世界终于清静了。

Tags:

TBCompressor – JS和CSS压缩工具

有朋友问到淘宝是怎么压缩js和css的,这里分享下。
我们使用的是YUI Compressor:

The YUI Compressor is a JavaScript compressor which, in addition to removing comments and white-spaces, obfuscates local variables using the smallest possible variable name. This obfuscation is safe, even when using constructs such as ‘eval’ or ‘with’ (although the compression is not optimal is those cases) Compared to jsmin, the average savings is around 20%.

The YUI Compressor is also able to safely compress CSS files. The decision on which compressor is being used is made on the file extension (js or css)

淘宝前端的开发环境以Windows居多。为了方便使用,对YUICompressor做了层简单的封装,称之为TBCompressor. 安装和使用方法如下:

安装说明

  1. 安装请点击install.cmd
  2. 卸载请点击uninstall.cmd
  3. 如果以前安装过2.3.5之前的版本, 请点击update.cmd升级

测试使用

  1. 在test.source.js上右键,执行菜单“压缩JavaScript”,会生成test.js文件。如果再对test.js文件执行一次压缩,会生成test-min.js文件
  2. CSS同1

下载试用

已更新:http://lifesinger.org/blog/?p=1253

Tags: ,

含中文字符的字符串长度校验

网上有不少解决方案,贡献下我使用的两个函数:

	/**
	 * 得到字符串的字符长度(一个汉字占两个字符长)
	 */
	function getBytesLength(str) {
		// 在GBK编码里,除了ASCII字符,其它都占两个字符宽
		return str.replace(/[^x00-xff]/g, 'xx').length;
	}

	/**
	 * 根据字符长来截取字符串
	 */
	function subStringByBytes(val, maxBytesLen) {
		var len = maxBytesLen;
		var result = val.slice(0, len);
		while(getBytesLength(result) > maxBytesLen) {
			result = result.slice(0, --len);
		}
		return result;
	}

一个实例:validation_check_length.html

Tags:

Page 34 of 38« First...1020303233343536...Last »