نمایش تاریخ

bamshad

Well-Known Member
سلام بچه ها
من این کد رو :
کد:
<META http-equiv=Content-Type content="text/html; charset=windows-1256"></HEAD>
<BODY>

      <SCRIPT>
function showdate() {
    week= new Array("يكشنبه","دوشنبه","سه شنبه","چهارشنبه","پنج شنبه","جمعه","شنبه")
    months = new Array("فروردين","ارديبهشت","خرداد","تير","مرداد","شهريور","مهر","آبان","آذر","دي","بهمن","اسفند");
    a = new Date();
    d= a.getDay();
    day= a.getDate();
    month = a.getMonth()+1;
    year= a.getYear();

 year = (year== 0)?2000:year;
 (year<1000)? (year += 2000):true;
    
 year -= ( (month < 3) || ((month == 3) && (day < 21)) )? 622:621;

 switch (month) {
     case 1: (day<21)? (month=10, day+=10):(month=11, day-=20); break;
     case 2: (day<20)? (month=11, day+=11):(month=12, day-=19); break;
     case 3: (day<21)? (month=12, day+=9):(month=1, day-=20);   break;
     case 4: (day<21)? (month=1, day+=11):(month=2, day-=20);   break;
     case 5:
     case 6: (day<22)? (month-=3, day+=10):(month-=2, day-=21); break;
     case 7:
     case 8:
     case 9: (day<23)? (month-=3, day+=9):(month-=2, day-=22);  break;
     case 10:(day<23)? (month=7, day+=8):(month=8, day-=22);    break;
     case 11:
     case 12:(day<22)? (month-=3, day+=9):(month-=2, day-=21);  break;
       default:   break;
 }
document.write(week[d]+" "+day+" "+months[month-1]+" "+ year);
}
                                  </SCRIPT>
                                        </FONT>

    print "document.write('"<SCRIPT>showdate()</SCRIPT>"');
با نام date.js سیو کردم
حالا می خوام اینو از یک صفحه دیگه فراخوانی کنم
کد:
<script  type="text/javascript" 
src="http://www.site.com/date.js">
</script>
و این کد رو می نویسم ولی ارور میده
لطفا" هرکسی میدونه مشکلش از کجاست بهم بگه ممنون
یا علی
 

bahy_my

Active Member
سلام سالار
شما نبايد تگ توي فايل جي اس بذاري
فايل js شما بايد اين باشه :
HTML:
function showdate() {
    week= new Array("يكشنبه","دوشنبه","سه شنبه","چهارشنبه","پنج شنبه","جمعه","شنبه")
    months = new Array("فروردين","ارديبهشت","خرداد","تير","مرداد","شهريور","مهر","آبان","آذر","دي","بهمن","اسفند");
    a = new Date();
    d= a.getDay();
    day= a.getDate();
    month = a.getMonth()+1;
    year= a.getYear();

 year = (year== 0)?2000:year;
 (year<1000)? (year += 2000):true;
    
 year -= ( (month < 3) || ((month == 3) && (day < 21)) )? 622:621;

 switch (month) {
     case 1: (day<21)? (month=10, day+=10):(month=11, day-=20); break;
     case 2: (day<20)? (month=11, day+=11):(month=12, day-=19); break;
     case 3: (day<21)? (month=12, day+=9):(month=1, day-=20);   break;
     case 4: (day<21)? (month=1, day+=11):(month=2, day-=20);   break;
     case 5:
     case 6: (day<22)? (month-=3, day+=10):(month-=2, day-=21); break;
     case 7:
     case 8:
     case 9: (day<23)? (month-=3, day+=9):(month-=2, day-=22);  break;
     case 10:(day<23)? (month=7, day+=8):(month=8, day-=22);    break;
     case 11:
     case 12:(day<22)? (month-=3, day+=9):(month-=2, day-=21);  break;
       default:   break;
 }
document.write(week[d]+" "+day+" "+months[month-1]+" "+ year);
}

showdate()
 

bahy_my

Active Member
سلام
خوبي ؟
من كردم كه گفتم.
ببين اينو بذار :
HTML:
<script src=date.js></script>
شايد درست شد.
آخه من امتحان كرده بودم.
 

bahy_my

Active Member
من اونو امتجان كردم . كار مي كرد.
احتمالاً توي تگ اسكريپتت يه مشكلايي وجود داره.
امتحان كن
 

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

بالا