Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java script useful function
Index -> Graphics and Design, Web Design -> (X)HTML Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Homer_simpson




PostPosted: Wed Aug 13, 2003 1:09 pm   Post subject: Java script useful function

I got this function from a tutorial it seems pretty useful so i post it here:

code:
function checkIfInstalled(fname){
   loaded = document.readyState == "complete";
   teststr = "font existence test"
   if(!window.fntLyr0) {
      lyrstr0 = "<SPAN ID=fntLyr0 STYLE='position:absolute;width:30;font:12pt Courier'>"+ teststr +"</SPAN>";
      lyrstr1 = "<SPAN ID=fntLyr1 STYLE='position:absolute;width:30;font-size:12pt'>"+ teststr +"</SPAN>";
      if (loaded) {
         document.body.insertAdjacentHTML("BeforeEnd",lyrstr0);     
         document.body.insertAdjacentHTML("BeforeEnd",lyrstr1);
      }
      else {
         document.write(lyrstr0);
         document.write(lyrstr1);
      }
   }
   fntLyr1.style.fontFamily = fname +",Courier";
   width0 = (isMac) ? fntLyr0.offsetWidth : fntLyr0.scrollWidth;
   width1 = (isMac) ? fntLyr1.offsetWidth : fntLyr1.scrollWidth;
   return (width0 != width1);
}


fname is the font name that yer checking to see if installed... then function reutrns a boolean to show whether it's installed or not...
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Graphics and Design, Web Design -> (X)HTML Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: