学习ajax插入文件上传框文档记录
[code]<!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>无标题文档</title>
<script>
/*
获取对象
objectId:对象的name或id
top:是否是顶级页面
s:如果有多个,是否要取多个多个。
*/
function getObject(objectId,top,s)
{
doc = top ?window.top.document:document;
if(typeof(objectId)!="object" && typeof(objectId)!="function")
{
if(doc.getElementById && doc.getElementById(objectId))
{
// W3C DOM 通过id获取对象
return doc.getElementById(objectId);
}else if(doc.getElementsByName(objectId))
{
// 通过name获取对象
var _obj = doc.getElementsByName(objectId);
}else if(doc.all && doc.all(objectId))
{
//IE 4.0及以上版本的专有属性
var _obj = doc.all(objectId);
}
else if (doc.layers && doc.layers[objectId])
{
// Netscape 4.x专有的属性
var _obj = doc.layers(objectId);
}
else
{
return false;
}
return s ? _obj : _obj[0];
}else
{
return objectId;
}
}
</script>
</head>
<body>
<div id="a"></div>
<input type="button" value="67676" onclick="test()" />
<script>
function test(){
var o = document.createElement("input");
o.type = "file";
getObject("a").appendChild(o);
}
</script>
</body>
</html>[/code] 我看不懂啊/:A039?
页:
[1]
