此功能只可在IE下使用。

博客园不提供使用 OBJECT 所以就无法在线演示了。

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
</head>
<body>
<OBJECT id="dlgHelper" CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px">
</OBJECT>
<input type="button" value="获取所有字体" onclick="getFont();" />
<input type="button" value="设置背景色" onclick="callColorDlg();" />
<script type="text/javascript">
function getFont()
{
var a=dlgHelper.fonts.count;
alert(a);
//show total number of system fonts
for (i = 1;i < dlgHelper.fonts.count;i++)
{
var f= f + " " + dlgHelper.fonts(i)
}
alert(f);
//show names of all system fonts
}

var sInitColor = null;
function callColorDlg(){

if (sInitColor == null)
var sColor = dlgHelper.ChooseColorDlg();
else
var sColor = dlgHelper.ChooseColorDlg(sInitColor);

sColor
= sColor.toString(16);
if (sColor.length < 6) {
var sTempString = "000000".substring(0,6-sColor.length);
sColor
= sTempString.concat(sColor);
}
sInitColor
= sColor;
document.body.style.backgroundColor
= '#' + sColor;
}

</script>
</body>
</html>



相关文章:

  • 2022-12-23
  • 2022-01-27
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2021-05-09
猜你喜欢
  • 2021-07-25
  • 2022-02-10
  • 2021-12-22
  • 2021-03-26
  • 2021-10-24
  • 2021-10-28
  • 2022-12-23
相关资源
相似解决方案