ورود

View Full Version : سوال: ساخت نوشته متحرک با جاوا اسکریپت



leghlegheh
شنبه 19 بهمن 1387, 17:54 عصر
با چه کدی (جاوا اسکریپت) می شه یک نوشته رو متحرک کرد
یعنی همون کاری که marquee در html انجام میده

as13851365
یک شنبه 20 بهمن 1387, 08:28 صبح
اگه جستجو می گردید پیداش می کردید ولی خوب چون همه با جستجو دشمنی دارن ....

کد زیر کمکت می کنه


<SCRIPT LANGUAGE="JavaScript">
var msg = "XXXXXXXXXXXXXXXXXXXXXX "
function scrollMsg(){
document.scrollerForm.welcomeMsg.value = msg
msg = msg.substring(1, msg.length) + msg.substring(0, 1)
setTimeout("scrollMsg()", 150)
}
</SCRIPT>

<BODY ONLOAD="scrollMsg()">
<FORM NAME="scrollerForm">
<INPUT TYPE="text" NAME="welcomeMsg" VALUE="" size=12>
</FORM>
</body>



<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="fa">
<title>بالا پايين کردن</title>
<style>
body
{
font-family:tahoma;
font-size:9pt;
}
.marquee
{
text-align: center;
direction: rtl;
border-style: solid;
border-width: 1px;
}
</style>
</head>

<body>

<marquee id="a" direction="up" height="114" width="132" class="marquee">متن شما</marquee>

<script>

function marquee(action)
{
document.getElementById('a').direction = action;
}

function stop()
{
document.getElementById('a').stop();
}

function start()
{
document.getElementById('a').start();
}


</script>

<br>

<br>

<span style="cursor:pointer" onmouseover="marquee('up');">بالا</span>&nbsp;&nbsp;
<span style="cursor:pointer" onmouseover="marquee('down');">پايين</span>&nbsp;&nbsp;
<span style="cursor:pointer" onmouseover="stop();" onmouseout="start();">ايست</span>

<p>&nbsp;</p>
<p>&nbsp;</p>

</body>

</html>


<script language="JavaScript">

function makeArray()
{
this.length = makeArray.arguments.length
for (var i = 0; i < this.length; i++)
this[i+1] = makeArray.arguments[i]
}

var fArray = new makeArray;
fArray[0]="HELLO TO MY BLOG Only sub design And Pack . "
fArray[1]="NEW IEDES..... For All time ...... . "
fArray[2]=" ================================================== ================================================== ================================================== ================================================== ================================================== =========="

var x = 1;
var y = 0;
var msg1 = fArray[y];

function newsFeed()
{
if (x==msg1.length+1)
{
for (var z=0; z < 7000; z++);
y+=1;
if (y >3) y=0;
document.form1.news2.value=' ';
msg1 = fArray[y];
x=0;
}
document.form1.news2.value=msg1.substring(0,x);
x+=1;
setTimeout("newsFeed() ",1);
}
</script>

<body bgcolor=teal link=goldenrod onLoad="newsFeed()">

<form name="form1">
<textarea wrap=physical rows=10 cols=25 name="news2">
</from>

leghleghe
سه شنبه 22 بهمن 1387, 19:08 عصر
از پاسختون سپاسگزارم

در ضمن من تازه واردم و با هیج چیز دشمنی ندارم

merlin69
پنج شنبه 06 اسفند 1388, 13:08 عصر
تو کد سوم نمی شه کاری کرد که بعد از این که متن ها تموم شد دوباره تکرار بشن؟

merlin69
پنج شنبه 06 اسفند 1388, 14:28 عصر
همچنین سرعتش کم شه و با فارسی هم مشکل نداشته باشد