| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 923 人关注过本帖
标题:HTML源代码 问候和变换背景
只看楼主 加入收藏
泰乐
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2006-1-6
收藏
 问题点数:0 回复次数:3 
HTML源代码 问候和变换背景

各位大侠下边代码是个变换背景颜色的代码 在我机器上怎么老出现错误,请教拉~~~~~
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用按钮更换网页背景色</title>
</head>

<body bgcolor="#fbe8f8">
<p align="center">
<big><big>
<font color="#0000ff"><b>用按钮更换网页背景色</b></font></big></big></p>
<hr>
<form>
<blockquote><blockquote><blockquote><p>
<input type="button" value="Papayawhip" onClick="document.bgcolor="papayawhip"">
<input type="button" value="blue" onClick="document.bgcolor="blue"">
<input type="button" value="gray" onClick="document.bgcolor="gray"">
<br>
<input type="button" value="lightcoral" onClick="document.bgcolor="lightcoral"">
<input type="button" value="white" onClick="document.bgcolor="white"">
<input type="button" value="red" onClick="document.bgcolor="red"">
<br>
<input type="button" value="whitesmoke" onClick="document.bgcolor="whitesmoke"">
<input type="button" value="orange" onClick="document.bgcolor="orange"">
<br>
<input type="button" value="dodgerblue" onClick="document.bgcolor="dodgerblue"">
<input type="button" value="yellow" onClick="document.bgcolor="yellow"">
<p>
</blockquote>
</blockquote>
</form>
</body>
</html>

下边是个显示浏览器版本的脚本 供大家享用:)
<script language="javascript">
<!--
//输出浏览器名称
document.write(navigator.appName)
//如果浏览器名称是Netscape
if(navigator.appName=="Netscape")
{
//输出Netscape的版本号
document.write(" "+navigator.appVersion)
}
//如果浏览器的名称是Microsoft Internet Explorer
if(navigator.appName=="Microsoft Internet Explorer")
{
//输出IE版本
document.write(" "+navigator.appVersion)
}
//-->
</script>

还有个问候的代码也有错误~~~诚心请教~~
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<script language="javascript">
now=new date()
hour=now.gethours()
if(hour<12){
document.write("<b>早上好,现在是:" +now.tolocalestring()+"")}
else if(hour<18){
document.write("<b>下午好,现在是:" +now.tolocalestring()+"")}
else if(hour>=18){
document.write("<b>晚上好,现在是:" +now.tolocalestring()+"")}
//获取浏览器的名称
var name=navigator.appName;
var vers=navigator.appVersion;
document.write("<br>很高兴结识你!愿我们是朋友!");
document.write("<br>您的浏览器是:"+name+"<br>");
document.write("版本号是:"+vers+"<br>");
document.write("推荐使用IE4.0,800*600*16位颜色模式");
</script>
</font>
</td>
</tr>
</table>
</body>
</html>
先谢谢拉~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

搜索更多相关主题的帖子: 源代码 HTML 问候 
2006-01-06 16:17
jingming
Rank: 1
等 级:新手上路
帖 子:116
专家分:0
注 册:2005-12-16
收藏
得分:0 

自己先背景色
在<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[i], 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[i], 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[i] blue hex
drawTable(hex[i])

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

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

// call function to begin execution
drawCube()

// -->
</script>


静坐当思已过,闲谈莫论人非!! 脸上的[快乐],别人看得到;心里的{痛},谁知道???
2006-01-06 17:17
泰乐
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2006-1-6
收藏
得分:0 

谢谢了~~~~~辛苦您了:)


成功源于执著!!!!
2006-01-08 18:29
泰乐
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2006-1-6
收藏
得分:0 
不过在浏览页面里有个颜色的 小框,点击那里边的颜色才能换色
我的按钮根本没用了 :(

成功源于执著!!!!
2006-01-08 18:35
快速回复:HTML源代码 问候和变换背景
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022329 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved