كود:
<style type="text/css">
#supertext {
position:absolute;
left:0;
top:0;
visibility:hide;
visibility:hidden;
}
</style>
<script language="JavaScript1.2">
//قم بتعيين الثلاث متغيرات التالية
//1) ضع هنا الجملة التى تريد مع العلم انها تقبل تنسيق الاتش تى ام ال
var thecontent='<h2><font color="#0000FF">مرحبا بكم فى الويب العربى</font></h2>'
//2) ضع الفترة التى ستبقى بها الرسالة على الشاشة .. ترك بين القوسين فارغ يعنى أنها ستظلّ فى حركة مستمرة ('' makes it incessantly visible on the screen)
var hidetimer='';
//3) ضع السرعة من 1- 50 وكلما زاد الرقم زادت السرعة
var BallSpeed = 20;
///لا تقم بالتعديل على الكود التالى///////////
var contentWidth;
var contentHeight;
var maxBallSpeed = 50;
var xMax;
var yMax;
var xPos = 0;
var yPos = 0;
var xDir = 'right';
var yDir = 'down';
var superballRunning = true;
var tempBallSpeed;
var currentBallSrc;
var newXDir;
var newYDir;
function initializeBall() {
if (dcidocument.all) {
xMax = dcidocument.body.clientWidth
yMax = dcidocument.body.clientHeight
dcidocument.all("supertext").style.visibility = "visible";
contentWidth=supertext.offsetWidth
contentHeight=supertext.offsetHeight
}
else if (dcidocument.layers) {
xMax = window.innerWidth;
yMax = window.innerHeight;
contentWidth=dcidocument.supertext.dcidocument.width
contentHeight=dcidocument.supertext.dcidocument.height
dcidocument.layers["supertext"].visibility = "show";
}
setTimeout('moveBall()',400);
if (hidetimer!='')
setTimeout("hidetext()",hidetimer)
}
function moveBall() {
if (superballRunning == true) {
calculatePosition();
if (dcidocument.all) {
dcidocument.all("supertext").style.left = xPos + dcidocument.body.scrollLeft;
dcidocument.all("supertext").style.top = yPos + dcidocument.body.scrollTop;
}
else if (dcidocument.layers) {
dcidocument.layers["supertext"].left = xPos + pageXOffset;
dcidocument.layers["supertext"].top = yPos + pageYOffset;
}
animatetext=setTimeout('moveBall()',20);
}
}
function calculatePosition() {
if (xDir == "right") {
if (xPos > (xMax - contentWidth - BallSpeed)) {
xDir = "left";
}
}
else if (xDir == "left") {
if (xPos < (0 + BallSpeed)) {
xDir = "right";
}
}
if (yDir == "down") {
if (yPos > (yMax - contentHeight - BallSpeed)) {
yDir = "up";
}
}
else if (yDir == "up") {
if (yPos < (0 + BallSpeed)) {
yDir = "down";
}
}
if (xDir == "right") {
xPos = xPos + BallSpeed;
}
else if (xDir == "left") {
xPos = xPos - BallSpeed;
}
else {
xPos = xPos;
}
if (yDir == "down") {
yPos = yPos + BallSpeed;
}
else if (yDir == "up") {
yPos = yPos - BallSpeed;
}
else {
yPos = yPos;
}
}
function hidetext(){
if (dcidocument.all)
supertext.style.visibility="hidden"
else if (dcidocument.layers)
dcidocument.supertext.visibility="hide"
clearTimeout(animatetext)
}
if (dcidocument.all||dcidocument.layers){
dcidocument.write('<span id="supertext"><nobr>'+thecontent+'</nobr></span>')
window.onload = initializeBall;
window.onresize = new Function("window.dcilocation.reload()");
}
</script>