当前位置: 代码迷 >> Java Web开发 >> 瀏覽器中取得系統字体的問題解决思路
  详细解决方案

瀏覽器中取得系統字体的問題解决思路

热度:161   发布时间:2016-04-17 13:38:06.0
瀏覽器中取得系統字体的問題
請教在瀏覽器即在javascript中怎麼樣取得系統的所有字體呢,
多謝了,急

------解决方案--------------------
<!--
宝玉
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> 获取当前系统字体和排版样式 </TITLE>

<SCRIPT LANGUAGE= "JavaScript ">
<!--
function getSystemFonts(){
var a=dlgHelper.fonts.count;
var fArray = new Array();
var oDropDown = document.all.fonts;
for (i = 1;i < dlgHelper.fonts.count;i++){
fArray[i] = dlgHelper.fonts(i);
var aOptions = oDropDown.options;
var oOption = document.createElement( "OPTION ");
aOptions.add(oOption);
oOption.text = fArray[i];
oOption.Value = i;
}
}

function getBlockFormats(){
var a=dlgHelper.blockFormats.count;
var fArray = new Array();
var oDropDown = document.all.formats;
oDropDown.setAttribute( "id ", "FormatList ");
for (i = 1;i < dlgHelper.blockFormats.count;i++)
{
fArray[i] = dlgHelper.blockFormats(i);
var aOptions = oDropDown.options;
var oOption = document.createElement( "OPTION ");
aOptions.add(oOption);
oOption.text = fArray[i];
oOption.Value = i;
}
}
//-->
</SCRIPT>
</HEAD>

<BODY onload= "getSystemFonts();getBlockFormats() ">
系统字体和排版样式 SystemFont and BlockFormats <BR>
<SELECT NAME= "fonts " onchange= "document.body.style.fontFamily = this.options[this.selectedIndex].text ">
</SELECT>
<SELECT NAME= "formats " onchange= "document.body.style.fontFamily = this.options[this.selectedIndex].text ">
</SELECT>
<OBJECT ID=dlgHelper CLASSID= "clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b " WIDTH= "0px " HEIGHT= "0px "> </OBJECT>
</BODY>
</HTML>
  相关解决方案