Předchozí Index Další

Rolovací reklamní plocha

Ukázka DownLoad



<HTML>
<HEAD>
<TITLE>JavaScript</TITLE>
</HEAD>
<BODY>
<IMG SRC="blank.gif" NAME="holdspace" ID="holdspace" WIDTH="390" HEIGHT="28" STYLE="visibility:hidden; position:relative;">

<SCRIPT LANGUAGE="JavaScript1.2">
<!--
var NS4 = (document.layers) ? true : false;
var IE4 = (document.all) ? true : false;

var interval = 20;
var increment = 1;
var pause = 1000;
var bannerColor = "yellow"
var leftPadding = 3;
var topPadding = 1;

var bannerLeft = (NS4) ? document.images.holdspace.x : holdspace.offsetLeft;
var bannerTop = (NS4) ? document.images.holdspace.y : holdspace.offsetTop;
var bannerWidth = (NS4) ? document.images.holdspace.width : holdspace.width;
var bannerHeight = (NS4) ? document.images.holdspace.height : holdspace.height;

var ar = new Array(
'<font size="5">Vitam vas na stranke www.javascript.sk</font>',
'<font size="5">     Na tychto strankach mozete najst</font>',
'<font size="5">    v sucasnej dobe vyse 170 skriptov.</font>',
'<font size="5"></font>',
''
);

onload = startBanner;

function showMessage(n, show) {
var whichEl = (NS4) ? eval("message" + n) :
eval("message" + n + ".style");
whichEl.visibility = (show) ? ((NS4) ? "show" : "visible") :
((NS4) ? "hide" : "hidden");
}

function nextMessage() {
var fromInd = current;
current = (fromInd == ar.length - 1) ? 0 : fromInd + 1;
scrollBanner(fromInd, current);
}

function moveUp() {
if (NS4) {
fromEl.top -= increment;
if (toEl.top - increment <= toElTarget) {
toEl.top = toElTarget;
clearInterval(intervalID);
fromEl.visibility = "hide"
timeoutID = setTimeout("nextMessage()", pause);
} else {
toEl.top -= increment;
}
} else {
fromEl.pixelTop -= increment;
if (toEl.pixelTop - increment <= toElTarget) {
toEl.pixelTop = toElTarget;
clearInterval(intervalID);
fromEl.visibility = "hidden"
timeoutID = setTimeout("nextMessage()", pause);
} else {
toEl.pixelTop -= increment;
}
}
}

function scrollBanner(from, to) {
if (NS4) {
fromEl = eval("message" + from);
toEl = eval("message" + to);
toEl.top = fromEl.top + bannerHeight;
toElTarget = fromEl.top;
} else {
fromEl = eval("message" + from + ".style");
toEl = eval("message" + to + ".style");
toEl.pixelTop = fromEl.pixelTop + bannerHeight;
toElTarget = fromEl.pixelTop;
}
showMessage(to, true);
intervalID = setInterval("moveUp()", interval);
}

function makeIE() {
var text = '<DIV ID="banner" STYLE="position:absolute">';
for (var i = ar.length - 1; i >= 0; i--) {
text += '<DIV ID="message' + i +
'" STYLE="position:absolute"></DIV>';
}
text += '</DIV>';

document.body.insertAdjacentHTML("BeforeEnd", text);

with (banner.style) {
width = bannerWidth;
height = bannerHeight;
clip = "rect(0 " + bannerWidth + " " + bannerHeight + " 0)"
backgroundColor = bannerColor;
pixelLeft = bannerLeft;
pixelTop = bannerTop;
}

for (i = 0; i < ar.length; i++) {
with (eval("message" + i + ".style")) {
visibility = "hidden"
pixelLeft = leftPadding;
pixelTop = topPadding;
width = bannerWidth - leftPadding;
backgroundColor = bannerColor;
}
}
}

function makeNS() {
banner = new Layer(bannerWidth);

with (banner) {
clip.right = bannerWidth;
clip.bottom = bannerHeight;
document.bgColor = bannerColor;
left = bannerLeft;
top = bannerTop;
visibility = "show"
}

for (var i = 0; i < ar.length; i++) {
eval("message" + i + " = " +
"new Layer(bannerWidth - leftPadding, banner)");
with(eval("message" + i)) {
visibility = "hide"
left = leftPadding;
top = topPadding;
document.bgColor = bannerColor;
}
}
}

function fillBanner() {
var whichEl;
if (NS4) {
for (var i = 0; i < ar.length; i++) {
whichEl = eval("message" + i);
whichEl.document.write(ar[i]);
whichEl.document.close();
}
} else {
for (var i = 0; i < ar.length; i++) {
whichEl = eval("message" + i);
whichEl.innerHTML = ar[i];
}
}
}

function startBanner() {
if (NS4)
makeNS()
else
makeIE();
fillBanner();
showMessage(0, true);
current = 0;
timeoutID = setTimeout("nextMessage()", pause);
}

//-->
</SCRIPT>
</BODY>
</HTML>