| 网站首页 | 模板 | 资料 | 源码 | 工具 | 开发 | 设计 | 安全 | 项目 | 网络 | 图片 | 系统 | 数据库 | 博客 | 会员中心 | 小说 | 
MYFTP 精品资料下载
网络学院
学习资料
源码模版
您现在的位置: 精品下载 >> 开发 >> 网站开发 >> CSS技术 >> 文章正文 用户登录 新用户注册
在网页中调用系统调色板和测试所有安装字体            【字体:
在网页中调用系统调色板和测试所有安装字体
作者:佚名    文章来源:不详    点击数:    更新时间:2007-12-18
  其实只是用到clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b这个控件的一些属性和方法而已,对于此控件的任何疑问,请查询MSDN
<style>
body,span,button{font-size:9pt;font-family:'Courier New' 宋体}
input,textarea{border:1px solid #000}
select{font-size:9pt;font-family:'Courier New' 宋体;width:150;height:10;background:#db811c}
</style>
<!--上面是为美观而定义的CSS-->
<script>
var oInitColor = "db811c" file://定义调色板的默认颜色
var oBject='<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>' file://控件代码,字体和调色板都是它方法属性的一部分
function oFonts(){
if(!document.getElementById('dlgHelper'))document.body.insertAdjacentHTML("AfterEnd",oBject) file://如果
var oOptions="<select onchange='demo.style.fontFamily=this.options[this.selectedIndex].value'><option>共找到"+dlgHelper.fonts.count+"种字体"
for (i=1;i<dlgHelper.fonts.count;i++)  file://循环输出字体
     oOptions+="<option value='"+dlgHelper.fonts(i)+"'>"+dlgHelper.fonts(i)
oOptions+="</select>"
list.innerHTML=oOptions
}

function oCP(){
if(!document.getElementById('dlgHelper'))document.body.insertAdjacentHTML("BeforeEnd",oBject)
var oColor = dlgHelper.ChooseColorDlg(oInitColor).toString(16) file://弹出调色板
oColor=((oColor.length < 6)?"000000".substring(0,6-oColor.length):"")+oColor file://按六位十六进制补齐返回颜色代码
demo.style.color="#"+oColor file://设置字体颜色
oInitColor=oColor file://对oInitColor重赋值,使打开调色板时的默认颜色为上次选中的颜色
}
</script>
font-size:<select style="width:40" onchange="demo.style.fontSize=this.options[this.selectedIndex].value+'pt'"><script>for(i=1;i<61;i++)document.write("<option value="+i+">"+i)</script></select>
    font-family:<span id=list>'Courier New'</span>
<br><input type=button onclick=oFonts() value="Show SysFonts">
    <input type=button onclick=oCP() value="Show ColorPanel">
<br><textarea style="width:100%;height:300" id=demo style="overflow:hidden;border:1px solid #999999">测试演示TestDemo</textarea>
  脚本效果需要IE5.5+的支持

文章录入:chqnet    责任编辑:chqnet 
  • 上一篇文章:

  • 下一篇文章:
  • 最新热点 最新推荐 相关文章
    CSS让网页中的内容自动换行的
    CSS自动实现网页打印版本
    使用html表格和CSS进行混合网
    进阶:网页CSS样式表设计十条
    Html网页页面head区规范知识
    用tabIndex轻松实现网页导航
    网页框架和网页框架集如何工
    网页设计引入CSS样式的五种方
    弹出网页窗口全攻略
    用CSS进行网页样式设计攻略全
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)