代码生成一个qq菜单编辑器!
把下列代码加到网页的<body></body>标签之间 从google下载我的照片管理软件<html>
<head>
<title>createcode</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<script language="javascript">
//生成代码
function createcode()
{
totalheight = parseint(fcreate.bodyheight.value) + fcreate.headheight.value * (fcreate.itemcount.value - 1);
textcode.value = text1.value +
"var headheight = " + fcreate.headheight.value + ";" +
"var bodyheight = " + fcreate.bodyheight.value + ";" +
"var objcount = " + fcreate.itemcount.value + ";" +
"var step = " + fcreate.mspeed.value + ";" +
text2.value +
".headtd1 {background: #" + fcreate.headcolorn.value + "; border: 2px outset; border-color: #" + fcreate.lbordern.value + " #" + fcreate.dbordern.value + " #" + fcreate.dbordern.value + " #" + fcreate.lbordern.value + "; cursor: hand; font-size: 9pt}" +
".headtd2 {background: #" + fcreate.headcolora.value + "; border: 2px outset; border-color: #" + fcreate.lbordera.value + " #" + fcreate.dbordera.value + " #" + fcreate.dbordera.value + " #" + fcreate.lbordera.value + "; cursor: hand; font-size: 9pt}" +
".bodytd{background: #" + fcreate.bodycolor.value + "; border: 2px outset; border-color: #" + fcreate.lborderb.value + " #" + fcreate.dborderb.value + " #" + fcreate.dborderb.value + " #" + fcreate.lborderb.value + "; font-size: 9pt}" +
text3.value +
"<div id='mainboard' style='position:absolute; left:2px; top:2px; width:120px; height:" + totalheight + "px; z-index:1; overflow: hidden; background: #" + fcreate.bodycolor.value + ";'> ";
itemtop = 0;
for (i = 1; i <= parseint(fcreate.itemcount.value); i++)
{
textcode.value += "<div id='item" + i + "body' style='position:absolute; left:0; top:" + itemtop + "; width:120px; height:" + fcreate.bodyheight.value + "px; z-index:" + (i+1) +"; overflow: hidden'>" +
"<table width='100%' border='0' height='100%' cellpadding='2' cellspacing='0'>" +
"<tr>" +
"<td id='item" + i + "head' height='" + (fcreate.headheight.value-2) + "' class=";
if (i == 1)
textcode.value += "'headtd2'";
else textcode.value += "'headtd1'";
textcode.value += " onclick='showme(item" + i + "body,this)' align='center'>";
//textcode.value += getvalue("fcreate.item" + i);
textcode.value +=document.all["item"+i].value+"</td>"+
"</tr>" +
"<tr>" +
"<td class='bodytd' align='center'>" +
"test" +
"</td>" +
"</tr>" +
"</table>" +
"</div>";
if (i == 1)
itemtop += parseint(fcreate.bodyheight.value);
else itemtop += parseint(fcreate.headheight.value);
}
textcode.value += "</div></body></html>"
}
//获取对象的值
function getvalue(obj)
{
//obj = object(obj);
return obj.value;
}
//清空代码
function clearcode()
{
textcode.value = "";
}
//预览代码
function prevcode()
{
createcode();
open().document.write(textcode.value);
}
//选择代码
function selectcode()
{
textcode.select();
}
//根据输入的数字,自动生成子菜单的填写项
function checkitems()
{
if ((fcreate.itemcount.value.length > 0 && isnan(fcreate.itemcount.value)) || fcreate.itemcount.value.length == 0)
{
alert("请输入数字!");
fcreate.itemcount.focus();
}
else
{
if (fcreate.itemcount.value > 50)
{
alert("太夸张了吧,小一点呀,不用这么玩命吧!(50以下,含50)")
fcreate.itemcount.focus();
return;
}
if (fcreate.itemcount.value < 1)
{
alert("太夸张了吧,一个不要你要做什么!(1以上,含1)")
fcreate.itemcount.focus();
return;
}
itemtext = "<table width='700' border='0' align='center' cellpadding='1' cellspacing='1'>";
for (i = 1; i <= fcreate.itemcount.value; i++)
{
itemtext += "<tr>"+
"<td class='td2' width='76'>菜单项目"+i+"</td>" +
"<td colspan='2' class='td2'>" +
" <input type='text' name='item" + i + "' class='back2' style='width:200' value='菜单" + i + "'>" +
"</td>" +
"<td class='td2' width='173'>菜 单 项 目 内容网页</td>" +
"<td colspan='2' class='td2'>" +
" <input type='file' name='itemsrc" + i + "' class='back2' style='width:200'>" +
"</td>" +
"</tr>";
}
itemtext+="</table>"
document.all.itemmenu.innerhtml = itemtext;
}
}
//检查是否是一个合法的颜色数值
function changebkclr(obj)
{
hexv = new array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
flag = false;
if (obj.value.length != 6)
{
alert("请用正确填写!(六位数)");
obj.focus();
}
else
{
for (i = 0; i < 6; i++)
{
for (j = 0; j <16; j++)
if (obj.value.charat(i).tolowercase() == hexv)
flag = true;
if (!flag)
{
alert("请用十六进制填写。(0-9,a-f)");
obj.focus();
return;
}
flag = false;
}
obj.style.background=obj.value;
}
}
//检查是否是一个合法的数字
function checknum(obj)
{
if (isnan(obj.value))
{
alert("请输入数字!");
obj.focus();
return;
}
}
//检查改变数值的速度合法性
function changespd(obj)
{
fcreate.mspeed.value = 1;
}
//检查是否是一个合法的速度
function checkspeed(obj)
{
if (isnan(obj.value))
{
alert("请输入数字!");
obj.focus();
}
else
{
if ((obj.form.bodyheight.value - obj.form.headheight.value)%obj.value != 0)
{
alert("请确认可以被 “菜单体高度 - 菜单题头高度” 整除");
obj.focus();
}
}
}
//控制总题目的填写
function ctrltitle(obj)
{
if (obj.value == "有")
obj.form.titlename.disabled = false;
else
obj.form.titlename.disabled = true;
}
</script>
<style type="text/css">
<!--
.td1{font-size: 9pt; background: #66ccff}
.td2{font-size: 9pt; background: #66aaff}
.back1 {font-size: 9pt; width:100}
.back2 {font-size: 9pt; background: #becfee}
-->
</style>
</head>
<body bgcolor='#ffffff' text='#000000'>
<div align="center">
<textarea name="textcode" rows="28" style="width:700" class="back2" readonly>
菜单项目个数 菜单题头高度 菜单体高度 填写移动速度
一 般 题 头 颜 色 亮 边 颜 色 暗 边 颜 色
当 前 题 头 颜 色 亮 边 颜 色 暗 边 颜 色
菜 单 主 体 颜 色 亮 边 颜 色 暗 边 颜 色
菜单 总题目 有 无 题目名称
菜单项目1 菜 单 项 目 内 容 网 页
菜单项目2 菜 单 项 目 内 容 网 页
<html>
<head>
<title>qq菜单</title>
<meta http-equiv='content-type' content='text/html; charset=gb2312'>
<script language='javascript'>
var moving = false;
function showme(obj1, obj2)
{
if (moving)
return;
moving = true;
for(i=0;i<document.all.tags('td').length;i++)
if (document.all.tags('td').classname.indexof('headtd') == 0)
document.all.tags('td').classname = 'headtd1';
obj2.classname = 'headtd2';
moveme(obj1);
}
function moveme(obj)
{
idnumber = parseint(obj.id.substr(4));
objtop = headheight * (idnumber - 1);
objbuttom = bodyheight + headheight * (idnumber - 2);
currenttop = parseint(obj.style.top);
if (currenttop >= objbuttom)
{
countid = 1;
for(i=0;i<document.all.tags('div').length;i++)
if (document.all.tags('div').id == 'item'+countid+'body')
{
obj = document.all.tags('div');
objtop = headheight * (countid - 1);
if (countid == idnumber)
{
moveup(obj,objtop,false);
break;
}
else
moveup(obj,objtop,true);
countid++;
}
}
else if ((currenttop <= objtop) && (idnumber < objcount))
{
idnumber++;
countid = objcount;
for(i=document.all.tags('div').length-1;i>=0;i--)
if (document.all.tags('div').id == 'item'+countid+'body')
{
obj = document.all.tags('div');
objbuttom = bodyheight + headheight * (countid - 2);
if (countid == idnumber)
{
movedown(obj,objbuttom,false);
break;
}
else
movedown(obj,objbuttom,true);
countid--;
}
}
}
function moveup(obj,objtop,ismove)
{
currenttop = parseint(obj.style.top);
if (currenttop > objtop)
{
obj.style.top = currenttop - step;
settimeout('moveup('+obj.id+','+objtop+','+ismove+')',1)
return;
}
moving = ismove;
}
function movedown(obj,objbuttom,ismove)
{
currenttop = parseint(obj.style.top);
if (currenttop < objbuttom)
{
obj.style.top = currenttop + step;
settimeout('movedown('+obj.id+','+objbuttom+','+ismove+')',1)
return;
}
moving = ismove;
}
</script>
</script>
<style type='text/css'>
</style>
</head>
<body bgcolor='#ffffff' text='#000000'>
页:
[1]