标题: 背景调色板
ljjk5
元帅
Rank: 1


荣誉会员奖章
UID 46706
精华 1
积分 99426
帖子 49691
威望 554
金币 48489
热心 505
阅读权限 100
注册 2007-2-25
状态 离线
背景调色板

脚本说明:
把如下代码加入<body>区域中
<script language="JavaScript">
<!--

// Copyright (c) 1996-1997 Tomer Shiran. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.geocities.com/~yehuda/

// create 6-element array
var hex = new Array(6)

// assign non-dithered descriptors
hex[0] = "FF"
hex[1] = "CC"
hex[2] = "99"
hex[3] = "66"
hex[4] = "33"
hex[5] = "00"

// accept triplet string and display as background color
function display(triplet) {
        // set color as background color
        document.bgColor = '#' + triplet

        // display the color hexadecimal triplet
        alert('现在的背景色是 #'+triplet)
}

// draw a single table cell based on all descriptors
function drawCell(red, green, blue) {
        // open cell with specified hexadecimal triplet background color
        document.write('<TD BGCOLOR="#' + red + green + blue + '">')

        // open a hypertext link with javascript: scheme to call display function
        document.write('<A HREF="javascript:display(\'' + (red + green + blue) + '\')">')

        // print transparent image (use any height and width)
        document.write('<IMG SRC="place.gif" BORDER=0 HEIGHT=12 WIDTH=12>')

        // close link tag
        document.write('</A>')

        // close table cell
        document.write('</TD>')
}

// draw table row based on red and blue descriptors
function drawRow(red, blue) {
        // open table row
        document.write('<TR>')

        // loop through all non-dithered color descripters as green hex
        for (var i = 0; i < 6; ++i) {
                drawCell(red, hex, blue)
        }

        // close current table row
        document.write('</TR>')
}

// draw table for one of six color cube panels
function drawTable(blue) {
        // open table (one of six cube panels)
        document.write('<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>')

        // loop through all non-dithered color descripters as red hex
        for (var i = 0; i < 6; ++i) {
                drawRow(hex, blue)
        }

        // close current table
        document.write('</TABLE>')       
}

// draw all cube panels inside table cells
function drawCube() {
        // open table
        document.write('<TABLE CELLPADDING=5 CELLSPACING=0 BORDER=1><TR>')

        // loop through all non-dithered color descripters as blue hex
        for (var i = 0; i < 6; ++i) {
                // open table cell with white background color
                document.write('<TD BGCOLOR="#FFFFFF">')

                // call function to create cube panel with hex blue hex
                drawTable(hex)

                // close current table cell
                document.write('</TD>')
        }

        // close table row and table
        document.write('</TR></TABLE>')
}

// call function to begin execution
drawCube()

// -->
</script>

网友 ljjk5 签名 - 网友社区 ===
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-9-5 14:09
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP