»
EnglishFrenchVietnamese

Print - Add image - JavaScriptBank.com

Full version: jsB@nk » Image » Add image
URL: http://www.javascriptbank.com/addimage.html

Add image © JavaScriptBank.comUser can add specified images in website by clicking link.

Full version: jsB@nk » Image » Add image
URL: http://www.javascriptbank.com/addimage.html



JavaScript
<SCRIPT language=JavaScript>var xLayerNo=0;function xLayer(xHtml, x, y, w){if(x==null)x=0;if(y==null)y=0;if(w==null)w=100;if(document.layers){this.layer=new Layer(w);this.layer.document.open();this.layer.document.write(xHtml);this.layer.document.close();this.layer.moveTo(x,y);this.images=this.layer.document.images;/*** These used to be prototypes (like  IE ) but when NS (communicator) 4.7 ***//*** first loads up, for some reason the prototypes do not get assigned ***/this.moveTo = function(x,y) { this.layer.moveTo(x,y); }this.moveBy = function(x,y) { this.layer.moveBy(x,y); }this.show= function() { this.layer.visibility = "show"; }this.hide = function() { this.layer.visibility = "hide"; }this.setzIndex= function(z){ this.layer.zIndex = z; }this.setBgColor = function(color) { this.layer.bgColor = color; }this.setBgImage = function(image) { this.layer.background.src = image; }this.getX = function() { return this.layer.left; }this.getY = function() { return this.layer.top; }this.getWidth = function() { return this.layer.width; }this.getHeight = function() { return this.layer.height; }this.getzIndex= function(){ return this.layer.zIndex; }this.isVisible = function() { return this.layer.visibility == "show"; }this.setContent   = function(xHtml){this.layer.document.open();this.layer.document.write(xHtml);this.layer.document.close();}this.clip = function(x1,y1, x2,y2){this.layer.clip.top=y1;this.layer.clip.left=x1;this.layer.clip.bottom=y2;this.layer.clip.right=x2;}}elseif(document.all){var xName="xLayer" + xLayerNo++;txt =   "<DIV ID='" + xName+ "' STYLE=\"position:absolute;"+ "left:"  + x + ";"+ "top:"   + y + ";"+ "width:" + w + ";"+ "visibility:hidden\">"+ xHtml + "</DIV>";document.body.insertAdjacentHTML("BeforeEnd",txt);this.content = document.all[xName];this.layer   = document.all[xName].style;this.images  = document.images;}return(this);}if(document.layers){/**** START prototypes for NS ***//*** END NS ***/}elseif(document.all){/*** START prototypes for IE ***/xLayer.prototype.moveTo = function(x,y){this.layer.pixelLeft = x;this.layer.pixelTop = y;}xLayer.prototype.moveBy = function(x,y){this.layer.pixelLeft += x;this.layer.pixelTop += y;}xLayer.prototype.show= function() { this.layer.visibility = "visible"; }xLayer.prototype.hide= function() { this.layer.visibility = "hidden"; }xLayer.prototype.setzIndex= function(z){ this.layer.zIndex = z; }xLayer.prototype.setBgColor= function(color) { this.layer.backgroundColor = color; }xLayer.prototype.setBgImage= function(image) { this.layer.backgroundImage = image; }xLayer.prototype.setContent   = function(xHtml){ this.content.innerHTML=xHtml; }xLayer.prototype.getX= function() { return this.layer.pixelLeft; }xLayer.prototype.getY= function() { return this.layer.pixelTop; }xLayer.prototype.getWidth= function() { return this.layer.pixelWidth; }xLayer.prototype.getHeight= function() { return this.layer.pixelHeight; }xLayer.prototype.getzIndex= function(){ return this.layer.zIndex; }xLayer.prototype.isVisible= function(){ return this.layer.visibility == "visible"; }xLayer.prototype.clip= function(x1,y1, x2,y2){this.layer.clip="rect("+y1+" "+x2+" "+y2+" "+x1+")";this.layer.pixelWidth=x2;this.layer.pixelHeight=y2;this.layer.overflow="hidden";}/*** END IE ***/}else{xLayer.prototype.moveTo = function(x,y) {  }xLayer.prototype.moveBy = function(x,y) {  }xLayer.prototype.show = function() {  }xLayer.prototype.hide = function() {  }xLayer.prototype.setzIndex= function(z) {  }xLayer.prototype.setBgColor = function(color) {  }xLayer.prototype.setBgImage = function(image) {  }xLayer.prototype.getX = function() { return 0; }xLayer.prototype.getY = function() { return 0; }xLayer.prototype.getWidth = function() { return 0; }xLayer.prototype.getHeight = function() { return 0; }xLayer.prototype.getzIndex= function(){ return 0; }xLayer.prototype.isVisible = function() { return false; }xlayer.prototype.setContent   = function(xHtml) { }}</SCRIPT><SCRIPT language=JavaScript>function xBrowser(){if(document.layers){this.getCanvasWidth= function() {return innerWidth;}this.getCanvasHeight= function() {return innerHeight;}this.getWindowWidth = function() {return outerWidth;}this.getWindowHeight= function() {return outerHeight;}this.getScreenWidth = function() {return screen.width;}this.getScreenHeight= function() {return screen.height;}this.getMinX= function() {return(pageXOffset);}this.getMinY= function() {return(pageYOffset);}this.getMaxX= function() {return(pageXOffset+innerWidth);}this.getMaxY= function() {return(pageYOffset+innerHeight);}}elseif(document.all){this.getCanvasWidth= function() {return document.body.clientWidth;}this.getCanvasHeight= function() {return document.body.clientHeight;}this.getScreenWidth= function() {return screen.width;}this.getScreenHeight= function() {return screen.height;}this.getMinX= function() {return(document.body.scrollLeft);}this.getMinY= function() {return(document.body.scrollTop);}this.getMaxX= function() {return(document.body.scrollLeft+document.body.clientWidth);}this.getMaxY= function() {return(document.body.scrollTop+document.body.clientHeight);}}return(this);}</SCRIPT><SCRIPT language=JavaScript>var Balls = new Array();var myBrowser;function CreateBalls(n){myBrowser = new xBrowser();for(x=0 ; x<n ; x++){addBall()}setTimeout("ani()", 50);}function addBall(){var i=Balls.length;Balls[i] = new xLayer("<IMG SRC='logojs.gif'>"+(i+1),23,0,20);Balls[i].x = 23;Balls[i].y = 0;Balls[i].dx = 5;Balls[i].dy = 5;Balls[i].show();}function ani(){for(i=0 ; i<Balls.length ; i++){var b = Balls[i];b.x += b.dx;b.y += b.dy;b.moveTo(b.x, b.y);if(b.dx > 0){if(b.x > myBrowser.getMaxX()-50)b.dx = -b.dx;}elseif(b.x < myBrowser.getMinX()-10)b.dx = -b.dx;if(b.dy > 0){if(b.y > myBrowser.getMaxY()-50)b.dy = -b.dy;}elseif(b.y < myBrowser.getMinY()-10)b.dy = -b.dy;}setTimeout("ani()", 25);}</SCRIPT><SCRIPT language=JavaScript>function start(){CreateBalls(1);}</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<BODY onload=start()><A href="javascript:addBall()">add a ball</A></BODY><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->