首先感谢楼主.
我作了以下修改.
把需要增加的JS函数加上在后台添加代码的一部分作为一个整体.
代码如下(需要加JS开始与结束):- <script language=javascript>
- function runCode(obj) {
- var winname = window.open('', "_blank", '');
- winname.document.open('text/html', 'replace');
- winname.document.writeln(obj.value);
- winname.document.close();
- }
- function saveCode(obj) {
- var winname = window.open('', '_blank', 'top=10000');
- winname.document.open('text/html', 'replace');
- winname.document.writeln(obj.value);
- winname.document.execCommand('saveas','','code.htm');
- winname.close();
- }
- function runCode(obj) {
- var winname = window.open('', "_blank", '');
- winname.document.open('text/html', 'replace');
- winname.document.writeln(obj.value);
- winname.document.close();
- }
- function saveCode(obj) {
- var winname = window.open('', '_blank', 'top=10000');
- winname.document.open('text/html', 'replace');
- winname.document.writeln(obj.value);
- winname.document.execCommand('saveas','','code.htm');
- winname.close();
- }
- </script>
- <br><textarea name='FF0' rows="15" cols="95">{1}</textarea><br><input type="button" value="运行代码" onclick="runCode(FF0)"> <input type="button" value="复制代码" onclick="copyCode(FF0)"> <input type="button" value="另存代码" onclick="saveCode(FF0)"> <script language=JavaScript>ffcod=delpost.FF0.value;ffcod=ffcod.replace(/<br \/>/g,'');delpost.FF0.value=ffcod;</script>提示:你可以先修改部分代码再运行<br>
复制代码 好像还是有点可以的.可是当我测试如下代码时.有点小错误.- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>滑动门</title>
- <style type="text/css">
- <!--
- #header {
- background-color: #F8F4EF;
- height: 200px;
- width: 400px;
- margin: 0px;
- padding: 0px;
- border: 1px solid #ECE1D5;
- font-family: "宋体";
- font-size: 12px;
- }
- #menu {
- margin: 0px;
- padding: 0px;
- list-style-type: none;
- }
- #menu li {
- display: block;
- width: 100px;
- text-align: center;
- float: left;
- margin: 0px;
- padding-top: 0.2em;
- padding-right: 0px;
- padding-bottom: 0.2em;
- padding-left: 0px;
- cursor: hand;
- }
- .sec1 { background-color: #FFFFCC;}
- .sec2 { background-color: #00CCFF;}
- .block { display: block;}
- .unblock { display: none;}
- -->
- </style>
- </head>
- <body>
- <script language=javascript>
- function secBoard(n)
- {
- for(i=0;i<menu.childNodes.length;i++)
- menu.childNodes[i].className="sec1";
- menu.childNodes[n].className="sec2";
- for(i=0;i<main.childNodes.length;i++)
- main.childNodes[i].style.display="none";
- main.childNodes[n].style.display="block";
- }
- </script>
- <div id="header">
- <ul id="menu">
- <li onMouseOver="secBoard(0)" class="sec2">六安新闻</li>
- <li onMouseOver="secBoard(1)" class="sec1">校园新闻</li>
- <li onMouseOver="secBoard(2)" class="sec1">最新日志</li>
- <li onMouseOver="secBoard(3)" class="sec1">论坛新帖</li>
- </ul>
- <!--内容显示区域-->
- <ul id="main">
- <li class="block">第一个内容</li>
- <li class="unblock">第二个内容</li>
- <li class="unblock">第三个内容</li>
- <li class="unblock">第四个内容</li>
- </ul>
- <!--内容显示区域-->
- </div>
- </body>
- </html>
复制代码
menu.childNodes[].className="sec1";
main.childNodes[].style.display="none";
[]会变成<>,不知道大家可有什么办法.
[ 本帖最后由 iboor 于 2007-1-15 06:58 编辑 ] |