ورود

View Full Version : اگر میشه یک سری farsnews.comبزنید .می خواهم اون منوی متحرک اول را داشته باشم .لطفا...



ali reza omid ali
یک شنبه 03 مهر 1384, 16:12 عصر
اگر میشه یک سری farsnews.comبزنید .می خواهم اون منوی متحرک اول را داشته باشم .لطفا...کمکم کنید

javad_hosseiny
دوشنبه 04 مهر 1384, 01:01 صبح
اگر سورس همان صفحه را ملاحظه می کردید سورس جاوا اسکریپتش را می دیدید
توضیحات جانبی اینکه:
ابتدا در دو متغیر (از نوع آرایه) لیست رشته موردنمایش و لینک مربوطه را تعریف می کنید و سپس یک فایل به نام fars.js دارد که کافی است تا آن را فراخوانی کنید


var theSummaries = new Array("1","2","3","4","5");
var theSiteLinks = new Array("link1","link2","link3","link4","link5");


و سپس فایل ضمیمه farsi.js را فراخوانی کنید

و بجای اعداد 1 تا 5 رشته دلخواه موردنظر را جایگزین کنید

persia2
دوشنبه 17 تیر 1387, 07:52 صبح
سلام

کد جاوا سایت فارس نیوز، اخبار رو به ترتیب نمایش میده. یعنی عنوان و لینک اخبار رو از متغیرهای زیر می گیره:


var theSummaries = new Array("1","2","3","4","5");
var theSiteLinks = new Array("link1","link2","link3","link4","link5");

و اول خبر 1، سپس خبر 2 و . . . رو نمایش میده.

من می خوام از ابتدا اخبار رو بصورت رندوم نشون بده. یعنی همیشه از 1 شروع نکنه و اخبار رو به ترتیب نشون نشده.

کد مربوطه:


// Control parameters
var theCharacterTimeout = 100;
var theStoryTimeout = 6000;
var theWidgetOne = "_";
var theWidgetTwo = "-";
var theWidgetNone = "";
var theItemCount = theSummaries.length;
var NS6=(document.getElementById && !document.all) ? true : false;

// Ticker startup

function startTicker()
{

// Define run time values
theCurrentStory = -1;
theCurrentLength = 0;
// Locate base objects
if (document.getElementById) {
runTheTicker();
}
else {
document.write("<style>.ticki{display:none;}.ticko{border:0px; padding:0px;}</style>");
return true;
}
}
// Ticker main run loop
function runTheTicker()
{
var myTimeout;
// Go for the next story data block
if(theCurrentLength == 0)
{
theCurrentStory++;
theCurrentStory = theCurrentStory % theItemCount;
theStorySummary = theSummaries[theCurrentStory];
theTargetLink = theSiteLinks[theCurrentStory];
}

var textTitle = theStorySummary.substring(0,theCurrentLength) + whatWidget();

if (theTargetLink ) {

if (NS6) {
document.getElementById("theTicker").innerHTML = '<a class=jstop target="_blank" href="'+ theTargetLink +'" target="_top">'+textTitle+'</a>';
}
else {
document.all.theTicker.innerHTML = '<a class=jstop target="_blank" href="'+ theTargetLink +'" target="_top">'+textTitle+'</a>';
}
}
else {
if (NS6) {
document.getElementById("theTicker").innerHTML = '<span>'+textTitle+'</span>';
}
else {
document.all.theTicker.innerHTML = '<span>'+textTitle+'</span>';
}
}

// Modify the length for the substring and define the timer
if(theCurrentLength != theStorySummary.length)
{
theCurrentLength++;
myTimeout = theCharacterTimeout;
}
else
{
theCurrentLength = 0;
myTimeout = theStoryTimeout;
}
// Call up the next cycle of the ticker
setTimeout("runTheTicker()", myTimeout);
}

// Widget generator
function whatWidget()
{
if(theCurrentLength == theStorySummary.length)
{
return theWidgetNone;
}

if((theCurrentLength % 2) == 1)
{
return theWidgetOne;
}
else
{
return theWidgetTwo;
}
}

startTicker();


ممنون میشم دوستان راهنمایی کنن. این توضیح رو هم بدم که من اصلا برنامه نویسی با جاوا رو بلد نیستم :خجالت:

با تشکر

persia2
سه شنبه 18 تیر 1387, 16:19 عصر
سلام

آیا از دوستان کسی نمی تونه کمک کنه؟

Coward
چهارشنبه 19 تیر 1387, 12:24 عصر
با سلام
کد فارسی را که داده بودین را امتحان کردم ولی به خط 48 ایراد می گیره و کار نمی کنه
document.all.theTicker is null or not object این اروری که می ده اگر می شود

Coward
شنبه 22 تیر 1387, 12:19 عصر
منون از دوستان مشکلم برطرف شد
کد را داخل یک <div> گذاشتم کار کرد

taknegaar
یک شنبه 30 تیر 1387, 03:46 صبح
http://www.smartmenus.org/vadikom/products/free-scripts/demos/nbar.html

taknegaar
یک شنبه 30 تیر 1387, 03:47 صبح
http://www.smartmenus.org/vadikom/products/free-scripts/demos/v_ex3.html
http://www.smartmenus.org/vadikom/products/free-scripts/demos/v_ex2.html
http://www.smartmenus.org/vadikom/products/free-scripts/demos/v_ex1.html