مشکل encode

MRB COMPANY

Member
سلام به دوستان عزیز
دنبال یه کد جاوا اسکریپت میگشتم تا لینک های مورد نظرم رو تایپ کنه.یعنی یه لینک رو تایپ می کنه بعد پاک میکنه و یه لینک دیگه رو تایپ میکنه.خیلی از سایتها از این اسکریپت استفاده میکنن.
ولی به یه مشکلی برخوردم

این اسکریپت حروف را یکی یکی تایپ میکنه.مثلا برای تایپ ( به وب سایت ما خوش آمدید ) شروع می کنه اول مینویسه (ب) بعد (ه) رو اضافه میکنه و ... که تا اینجا درسته
ولی اطلاعات و متون من که از دیتابیس خونده میشه مثلا برای جمله بالایی اینجوریه (به وب سای..... )

وقتی این اسکریپت شروع میکنه به کار تمامی حروف رو به ترتیب می نویسه !!!!(خدا کنه درست منظورم رو گفته باشم)

حالا نمیدونم از چه طریقی کاری کنم حرف به حرف درست کار کنه؟؟

مثلا کد php معرفی کنید تا این حروف رو ترجمه کنه به اصل کلمه مثلا (ب) رو بنویسه (ب) البته اگه به نظرتون از این طریق مشکل برطرف میشه یا یه کدی که مشکل رو حل میکنه
مشکلم encode .حالا میگید چیکا کنم؟
:cry:
نمی دونم باید از چه روشی استفاده کنم:shock:
ممنون
 

MRB COMPANY

Member
خودم یافتم!

رو کد کار کردم و یه چی از توش درآواردم که فکر کنم خوب باشه
میزارم اینجا تا اگه کسی مشکل منو داشت بتونه ازش استفاده کنه
:)
HTML:
<div id="theTicker"></div>

<script type="text/javascript" language="JavaScript">
var theSummaries = new Array('متن لینک 1','متن لینک 2','متن لینک 3');
var theSiteLinks = new Array('url 1','url 2','url 3');

// Control parameters
var theCharacterTimeout = 50;
var theStoryTimeout     = 5000;
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];
    }
    timeandremove=theCurrentLength;
    if(theStorySummary.substring(theCurrentLength-1,theCurrentLength)=='&'){timeandremove--;}
    
    var textTitle = theStorySummary.substring(0,timeandremove) + whatWidget();

    if (theTargetLink ) {

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

    // Modify the length for the substring and define the timer
    if(theCurrentLength != theStorySummary.length)
    {
        //theCurrentLength++;
        if(theStorySummary.substring(theCurrentLength-1,theCurrentLength)=='&'){
            theCurrentLength=theCurrentLength+6;
            /*if(theStorySummary.substring(theCurrentLength-1,theCurrentLength)==';'){
                alert('j');
            }*/
        }else{
            theCurrentLength=theCurrentLength+1;
        }
        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();

</script>
 

جدیدترین ارسال ها

بالا