免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1610 | 回复: 0
打印 上一主题 下一主题

网页拾色器 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-08-13 10:27 |只看该作者 |倒序浏览
    在动态网站中,经常会有允许用户在客户端自定义颜色显示某些信息的情况,如留言板的颜色,这可以通过在网页中加入一个拾色器来实现,当用户单击颜色块时,弹出拾色器供选择,当用户选择完毕后,关闭拾色器,并把选中的颜色赋予颜色块,在当用户用拾色器时 还要显示该颜色的颜色值

    首先,创建需要调用网页拾色器的页面,我在这里定义为 index.jsp
script language="javascript">
function colorpick(field){
   var rtn = window.showModalDialog("color.jsp","","dialogWidth:225px;dialogHeight:170px;status:no;help:no;scrolling=no;scrollbars=no");
   if(rtn!=null)
    field.style.background=rtn;
     return;
   }
/script>
body>
   选择颜色 :
                                input name="color" type="text" id="color" size="3" readonly="yes" style="background-color:#000000" onClick="colorpick(this);">
/body>


其次,建立拾色器页面 color.jsp

%@ page contentType="text/html; charset=gb2312" language="java"%>
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
html>
head>
meta http-equiv="Content-Type" content="text/html; charset=gb2312">
title>网页拾色器/title>
/head>
body>
script language="JavaScript">
');
document.write('');
document.write('');
document.write('');
document.write('');
}
function Mtr(R, B) {
document.write('');
for (var i = 0; i ')
}
function Mtable(B) {
document.write('');
for (var i = 0; i ');
}
function Mcube() {
document.write(''); //
for (var i = 0; i ');
   }
  document.write('');
  Mtable(h)
  document.write('');
}
   if(i%3==0){
   document.write('');
   }
document.write('');
}
Mcube()
-->
  
/script>
/body>
/html>

   完毕,大家可以当作工具使用,以后当做某些项目的时候,比如具有UBB功能的在线论坛,网站聊天室或者网页换肤功能的时候 就可以运用本实例! 呵呵


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/72940/showart_1129524.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP