Tuesday, June 12, 2012

scroll title with javascript

Deface page ေတြေရးတဲ႔အခါ Title ေလးေတြ scrolling ျဖစ္ေနတာကို ေတြ႕ရပါတယ္

ဒါကိုဘယ္လိုေရးမလဲလို႔စဥ္းစားမိတဲ႔အခါ

online မွာရွိတဲ႔ source code ေတြကိုရွာမိပါတယ္

သူတို႔ေရးထားတာက ဒီလိုပါ
//Document title scroller- By Graeme Robinson (me@graemerobinson.co.uk)
//Exlusive permission granted to Dynamic Drive to include this script in their DHTML archive.
//For full source code, terms of use visit http://www.dynamicdrive.com
var repeat=1 //enter 0 to not repeat scrolling after 1 run, othersise, enter 1
var title=document.titlevar leng=title.lengthvar start=1
function titlemove() {
  titl=title.substring(start, leng) + title.substring(0, start)
  document.title=titl
  start++
  if (start==leng+1) {
        start=0
        if (repeat==0)
        return
  }
  setTimeout("titlemove()",140)
}
if (document.title)
titlemove()

ဟီး သူေရးတာၾကည္ေတာ႔ နည္းနည္းေတာင္လည္သြားတယ္

ဒါေပမယ္႔ တားက နည္းနည္းေလးသူဟာကိုတိုသြားေအာင္လုပ္လိုက္တယ္ တစ္မ်ိဳးမထင္နဲ႔ ကုတ္ကိုေျပာတာ

ေရးနည္းက ဒီလိုေလးပါ
var title="~~Opps!";
var speed=100;
function scrolltitle()
{
document.title=title;
title=title.substring(1,title.length) + title.charAt(0);
setTimeout("scrolltitle()",speed);
}
scrolltitle();
တူတူပဲ႔ ေအာက္ကဟာက ပိုလြယ္မယ္ထင္တယ္
     
      

No comments:

Post a Comment

Thanks for your comments
Welcome from cyberoot