>>2
この場合,削除は一番やってはいけない行為です。「マルチポスト クロスポスト」あたりで検索してみて,しかるべき処置をとって下さい。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>プログレスバー</title>
<script type="text/javascript">
if (document.implementation
&& (window.addEventListener || window.attachEvent)
&& Function.prototype
&& Function.prototype.call)
var ProgressBar = (function () {
////////////////////////////////////////////////////////////////////////
function Timer (msec) {
this.timeOut = msec || 1000;
this.timerID = null;
this.timerListener = null;
}
Timer.prototype.addTimerListener = function (listener) {
this.timerListener = listener;
};
Timer.prototype.start = function () {
this.timerID = function (thisObj, callback) {
return setTimeout (
function() {
thisObj.timerListener ();
callback.call (thisObj);
},
thisObj.timeOut
);
} (this, arguments.callee);
};
Timer.prototype.stop = function () {
clearTimeout (this.timerID);
};
//______________________________________________________________________
function ComputedStyle () {
this.width = '0px';
this.height = '1em';
this.background = '#999';
this.border = '1px solid #222';
}
ComputedStyle.prototype.expand = function (pixelWidth) {
this.width = (parseInt (this.width) + pixelWidth) + 'px';
};
//______________________________________________________________________
function ProgressBar () {
Timer.apply (this, arguments);
this.targetNode = document.createElement ('p');
ComputedStyle.call (this.targetNode.style);
};
ProgressBar.prototype = new Timer;
ProgressBar.prototype.constructor = ProgressBar;
ProgressBar.prototype.increase = function () {
ComputedStyle.prototype.expand.apply (this.targetNode.style, arguments);
};
ProgressBar.prototype.addEventListener = function (type, listener, useCapture) {
this.targetNode./*@cc_on @if (@_jscript) attachEvent ('on' + @else @*/
addEventListener (/*@end @*/ type, listener, useCapture);
};
//______________________________________________________________________
ProgressBar.create = function () {
var pb = new this (60);
document.body.appendChild (pb.targetNode);
pb.addTimerListener (function () {
this.increase (2);
} );
pb.addEventListener ('mouseup', function (e) {
pb.stop ();
}, false);
pb.start ();
};
return ProgressBar;
////////////////////////////////////////////////////////////////////////
} )();
</script>
<p style="cursor: pointer; " onclick="ProgressBar.create (); ">プログレスバー追加</p>