JavaScript判断上传文件的大小
<form name="form1">
<input type="file" name="file1" onchange="checkimage
(value)">
</form>
<script language="javascript">
var img=null;
function checkimage(name){
if(/^.+\.(gif|jpg|png)$/i.test(name))
{
if(img)img.removeNode(true);
img=document.createElement("img");
img.style.position="absolute";
img.style.visibility="hidden";
img.attachEvent("onerror",oe);
img.attachEvent("onreadystatechange",orsc);
document.body.insertAdjacentElement("beforeend",img);
img.src=name;
}
else{oe()}
}
function oe(){
form1.reset();
alert("文件类型只能是<gif><jpg><png>!");
}
function orsc(){
if (img.fileSize>51200){
form1.reset();
alert("文件大小不能超过50K!");
}
}
</script>
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js除去字符串空格 ......
效果图
代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Scrollable</title>
<mce:script type="text/javascript"><!--
resizeCallback = function() {
......
第一种 JavaScript连接数据库:
<mce:script language="JavaScript"><!--
// 创建数据库对象
var objdbConn = new ActiveXObject("ADODB.Connection");
// DSN字符串
var strdsn = "Driver={SQL Server};SERVER=192.168.0.210;UID=xhb;PWD=xhb;DATABASE=books";
// 打开数据源
objdbConn.Open(strdsn);
// ......
document.close();
document.open();
function jsonFormat(template, json) {
return template.replace(/\$\{(.+?)\}/g, function ($, $1) {
return json[$1];
});
}
var links = [
{ text: "人肉搜索", url: "http://renrousousuo.com" } ,
{ text: "CSDN", url: &qu ......