日期:2014-05-16 浏览次数:20396 次
<html>
<body>
<script>
function showWindow(title,content,size) {
this.title = title;
this.content = content;
this.size = size;
var date = new Date();
this.objid = date.getHours() + "" + date.getMinutes() + "" + date.getSeconds() + "" + date.getMilliseconds();
}
showWindow.prototype = {
show: function (type, autoClose) {
var divObj = document.createElement("div");
//divObj.id = 'window_' + this.objid;
divObj.style.width = this.size[0] + 'px';
divObj.style.height = this.size[1] + 'px';
//divObj.style.position = "absolute";
divObj.style.border = "1px #ccc solid";
divObj.innerHTML = '<div style="width:10px;height:10px"></div><input type="button" value="关闭" onclick="closeWindow()" style="float:right" />';
document.body.appendChild(divObj);
this.closeWindow = function () {
document.body.removeChild(divObj);
}
if (autoClose > 0) {
setTimeout(function () {
document.body.removeChild(divObj);
}, autoClose * 1000);
}
closeWindow = function () {
document.body.removeChild(divObj);
}
}
}
function test1(){
var size1 = new Array('100', '100');
var s = new showWindow('aaa', 'bbb', size1);
s.show({ 'type': '0' }, 0);
}
function test2(){
var size1 = new Array('150', '150');
var s = new showWindow('ccc', 'ddd', size1);
s.show({ 'type': '0' }, 0);
}
</script>
<input type="button" value="测试1" onclick="test1()" />
<input type="button" value="测试2" onclick="test2()" />
</body>
</html>