Js控制输入字符数限制
From: http://www.phpcake.cn/archives/26/
<script type="text/javascript">
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}
</script>
<textarea maxlength="10" onkeyup="return ismaxlength(this)"></textarea>
Tags: javascript
自动等比例缩放网页中的图片
resizeimg.js
window.onload = function() {
for (var index = 0; index < document.images.length; index++) {
var widthRestriction = 400;
var heightRestriction = 400;
var rate = document.images[index].width / document.images[index].height;
if (document.images[index].width > widthRestriction) {
document.images[index].width = widthRestriction;
[...]
