Здравейте, намерих един много добър скрипт(по-надолу е даден), та да Ви питам може ли да се направи като цъкна примерно банера на wt в див-а да пише "Здрасти", а като натисна 905/542 например да пише "Чао" ?
Ето кода:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<style type="text/css">
#picContainer {
width: 200px;
height: 200px;
margin: 0 auto;
background-color: #FFFFFF;
border: 1px solid #000000;
}
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
</style>
<script type="text/javascript">
function elementResizeTo(el, w, h)
{
el.style.width = w +'px';
el.style.height = h +'px';
}
function animationResize(element)
{
this.element = document.getElementById(element);
}
animationResize.prototype.startResize = function(targetWidth, targetHeight, step)
{
this.elementWidth = this.element.offsetWidth;
this.elementHeight = this.element.offsetHeight;
this.targetWidth = targetWidth;
this.targetHeight = targetHeight;
this.step = (!step) ? 10 : step;
this.xStep = (this.elementWidth - this.targetWidth) / this.step;
this.yStep = (this.elementHeight - this.targetHeight) / this.step;
this.calculateOffset();
}
animationResize.prototype.calculateOffset = function()
{
if (this.step <= 0) return;
this.elementWidth -= this.xStep;
this.elementHeight -= this.yStep;
this.step --;
elementResizeTo(this.element, this.elementWidth, this.elementHeight);
var self = this;
setTimeout(function(){self.calculateOffset()}, 10);
}
var moveObj = null;
window.onload = function()
{
moveObj = new animationResize('picContainer');
}
</script>
</head>
<body>
<button onclick="moveObj.startResize(253, 312, 13)">253/312</button>
<button onclick="moveObj.startResize(358, 372, 13)">358/372</button>
<button onclick="moveObj.startResize(905, 542, 13)">905/542</button>
<p><img src="http://web-tourist.net/webtourist.gif" alt="pic" border="0" onclick="moveObj.startResize(253, 312, 13)"> </p>
<p> </p>
<p> </p>
<div id="picContainer"></div>
</body>
</html>
Ето кода:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<style type="text/css">
#picContainer {
width: 200px;
height: 200px;
margin: 0 auto;
background-color: #FFFFFF;
border: 1px solid #000000;
}
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
</style>
<script type="text/javascript">
function elementResizeTo(el, w, h)
{
el.style.width = w +'px';
el.style.height = h +'px';
}
function animationResize(element)
{
this.element = document.getElementById(element);
}
animationResize.prototype.startResize = function(targetWidth, targetHeight, step)
{
this.elementWidth = this.element.offsetWidth;
this.elementHeight = this.element.offsetHeight;
this.targetWidth = targetWidth;
this.targetHeight = targetHeight;
this.step = (!step) ? 10 : step;
this.xStep = (this.elementWidth - this.targetWidth) / this.step;
this.yStep = (this.elementHeight - this.targetHeight) / this.step;
this.calculateOffset();
}
animationResize.prototype.calculateOffset = function()
{
if (this.step <= 0) return;
this.elementWidth -= this.xStep;
this.elementHeight -= this.yStep;
this.step --;
elementResizeTo(this.element, this.elementWidth, this.elementHeight);
var self = this;
setTimeout(function(){self.calculateOffset()}, 10);
}
var moveObj = null;
window.onload = function()
{
moveObj = new animationResize('picContainer');
}
</script>
</head>
<body>
<button onclick="moveObj.startResize(253, 312, 13)">253/312</button>
<button onclick="moveObj.startResize(358, 372, 13)">358/372</button>
<button onclick="moveObj.startResize(905, 542, 13)">905/542</button>
<p><img src="http://web-tourist.net/webtourist.gif" alt="pic" border="0" onclick="moveObj.startResize(253, 312, 13)"> </p>
<p> </p>
<p> </p>
<div id="picContainer"></div>
</body>
</html>