<script type="text/javascript">
Object.reEvent = function () {
//获取Event
return window.event ? window.event : (function (o) {
do {
o = o.caller;
} while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
return o.arguments[0];
})(this.reEvent);
};
var $P = {
reMouse : function () {
//获取鼠标绝对位置
var e = Object.reEvent();
return {
x : (document.documentElement.scrollLeft || document.body.scrollLeft) + e.clientX,
y : (document.documentElement.scrollTop || document.body.scrollTop) + e.clientY
};
}
};
function submit() {
document.form1.submit();
}
var show = function () {
var mos = $P.reMouse(), wc = document.getElementById("wc");
with (wc.style) {
left = mos.x - 200 + "px";
top = mos.y - 10 + "px";
}
};
</script>
先添加一个附件,然后提交,这时提示拒绝访问错误!
<form id="form1">
<div>
<input type="file" name="file" id="wc" style="top:0px;height:20px;position:absolute;opacity:0;filter:alpha(opacity=50);" onchange="abc.click();">
</div>
<input type="button" value="增加" onmousemove="show()">
<input type="button" value="提交" id="abc" onclick="submit()">
</form>
我改写后JS的代码,只是参照,要根据需求来做的。。
--------------------------------------------------------------------------------------------------------
<script type="text/javascript">
var fileObject = {
move: function(fileId) {
var posX = (document.documentElement.scrollLeft || document.body.scrollLeft) + event.clientX;
var posY = (document.documentElement.scrollTop || document.body.scrollTop) + event.clientY;
with (document.getElementById(fileId).style) {
left = posX - 200 + "px";
top = posY - 10 + "px";
}
},
click: function(tableId, raiseEventId) {
var raiseEventObject = document.getElementById(raiseEventId);
var table = document.getElementById(tableId);
var rows = table.rows;
var currentRow = null;
for (var i = 0; i < rows.length; i++) {
var inputs = rows[i].cells[0].all.tags("INPUT");
if (inputs != null) {
for (var j = 0; j < inputs.length; j++) {
if (inputs[j].type == "checkbox") {
if (inputs[j].checked) currentRow = rows[i];
break;
}
}
}
if (currentRow != null) break;
}
if (currentRow == null) {
raiseEventObject.click();
return false;
} else {
var inputs = currentRow.cells[currentRow.cells.length - 1].all.tags("INPUT");
if (inputs.length > 0) {
return confirm("File already exist, are you sure?");
}
return true;
}
},
change: function(raiseEventId) {
var raiseEventObject = document.getElementById(raiseEventId);
if (raiseEventObject != null && raiseEventObject.click()) {
raiseEventObject.click();
}
}
};
</script>
浙公网安备 33010602011771号