关于document.write()方法 document.write()是容易让页面其他的内容变没有了。你可以用form.innerHTML += "<div></div>"这种方式实现啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE> New Document </TITLE><META NAME="Generator" CONTENT="EditPlus"><META NAME="Author" CONTENT=""><META NAME="Keywords" CONTENT=""><META NAME="Description" CONTENT=""><script language="javascript" type="text/JavaScript">//首先定义两个数组,一个是菜单文字,一个是链接 var MenuText = new Array(3); var MenuEven = new Array(3); MenuText[1] = ["菜单11","菜单12","菜单13"]; MenuText[2] = ["菜单21","菜单21"]; MenuText[3] = ["菜单31","菜单321","菜单33"]; MenuEven[1] = ["url11","url12","url13"]; MenuEven[2] = ["url21","url22"]; MenuEven[3] = ["url31","url32","url33"];//初始化一个oPopup对象var oPopup = window.createPopup();//这两个是获得表格绝对位置的方法,很有用的说function getLeftIE(x,m) { var dx=0; if (x.tagName=="TD"){ dx=x.offsetLeft; } else if (x.tagName=="TABLE") { dx=x.offsetLeft; if (m) { dx+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; } } return dx+(x.parentElement.tagName=="BODY"?0:getLeftIE(x.parentElement,m));}function getTopIE(x,m) { var dy=0; if (x.tagName=="TR"){ dy=x.offsetTop; } else if (x.tagName=="TABLE") { dy=x.offsetTop; if (m) { dy+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; } } return dy+(x.parentElement.tagName=="BODY"?0:getTopIE(x.parentElement,m));}//显示菜单function ButtonClick(node,t){ alert("123"); //首先得到鼠标所在的表格的位置 var left = getLeftIE(node,true)-8; var top = getTopIE(node,true);//定义打开的oPopup的宽度,高度 var width = 90; var height = MenuText[t].length*20; // var width = 400; // var height = 100; //清空oPopup的内容,否则每次调用都只会在后面接着写 oPopup.document.body.innerHTML = ""; var b=document.getElementById("table1").innerHTML.toString(); //alert(b); //alert(document.getElementById("table1").innerText.toString()); var c=document.getElementById("table1").innerText.toString(); var oPopBody = oPopup.document.body; oPopup.show(left,top, width, height, document.body); oPopup.document.open;//让oPopup在鼠标离开时自动隐藏。 oPopup.document.write("<body leftmargin=0 topmargin=0 scroll=no style='border : 0 px;bgColor:#cccccc' onmouseover=clearTimeout(parent.popt); onmouseout=parent.popt=setTimeout('parent.oPopup.hide()',10);>");//用document.write()写菜单内容 oPopup.document.write("<table width=100% height=100% style='border-collapse : collapse;'>"); for(var i=0;i<MenuText[t].length;i++) { oPopup.document.write("<tr><td background='image/topbg.gif' bgcolor=#cccccc style='border-top : #cccccc 1px solid;border-bottom : #666666 1px solid;border-left : #cccccc 1px solid;border-right : #666666 1px solid;mouse : hand; font-size : 12px; color:#000000;text-align : left;vertical-align : center;CURSOR: hand' onmouseover=this.bgColor='#C2D2E5'; onmouseout=this.bgColor='#cccccc'; height='20' onclick='parent.parent.main.location.href=\""+MenuEven[t][i]+"\"';>"+MenuText[t][i]+"</td></tr>"); } oPopup.document.write("</table></td></tr></table>"); //alert("nnnnn") //oPopup.document.write("<table>"); //oPopup.document.write(b); //oPopup.document.write("<tr><td>3333</td></tr>"); //oPopup.document.write("</table>"); // alert("mmmm") oPopup.document.write("</body>")}</script></HEAD><BODY><table><tr><td align="left" onclick="ButtonClick(this,1)">菜单1</td></tr><br><tr><td height="200"></td></tr><br></table><table id="table1"><tr><td align="left" >菜单3</td></tr><br><tr><td align="left" style="color:red" >菜单4</td><br></BODY></HTML> DOM做这种动态伸展是比较方便的办法. 求高手指点,javascrip 选择器 跪求 如何访问远程服务器 这两天在学jQuery,又碰到jQuery ui了,没搞懂! setTimeout函数执行 某个对象本身的方法函数,怎么写也不对,救急。 javascript 调用activeX中的方法,如何传入传出参数? 请人帮忙看一下JS的功能修改问题 javascript 转 C 的一个小问题 如何点击一个链接后,弹出一个保存当前html页的对话框?急中.... 求助!在线等待! 两个关于opera浏览器的问题 请高手进来帮忙! 如何在表格中合并列?
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="javascript" type="text/JavaScript">
//首先定义两个数组,一个是菜单文字,一个是链接
var MenuText = new Array(3);
var MenuEven = new Array(3);
MenuText[1] = ["菜单11","菜单12","菜单13"];
MenuText[2] = ["菜单21","菜单21"];
MenuText[3] = ["菜单31","菜单321","菜单33"]; MenuEven[1] = ["url11","url12","url13"];
MenuEven[2] = ["url21","url22"];
MenuEven[3] = ["url31","url32","url33"];
//初始化一个oPopup对象var oPopup = window.createPopup();//这两个是获得表格绝对位置的方法,很有用的说
function getLeftIE(x,m) {
var dx=0;
if (x.tagName=="TD"){
dx=x.offsetLeft;
}
else if (x.tagName=="TABLE") {
dx=x.offsetLeft;
if (m) { dx+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
}
return dx+(x.parentElement.tagName=="BODY"?0:getLeftIE(x.parentElement,m));
}
function getTopIE(x,m) {
var dy=0;
if (x.tagName=="TR"){
dy=x.offsetTop;
}
else if (x.tagName=="TABLE") {
dy=x.offsetTop;
if (m) { dy+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
}
return dy+(x.parentElement.tagName=="BODY"?0:getTopIE(x.parentElement,m));
}//显示菜单
function ButtonClick(node,t)
{ alert("123");
//首先得到鼠标所在的表格的位置
var left = getLeftIE(node,true)-8;
var top = getTopIE(node,true);
//定义打开的oPopup的宽度,高度
var width = 90;
var height = MenuText[t].length*20;
// var width = 400;
// var height = 100;
//清空oPopup的内容,否则每次调用都只会在后面接着写
oPopup.document.body.innerHTML = "";
var b=document.getElementById("table1").innerHTML.toString();
//alert(b);
//alert(document.getElementById("table1").innerText.toString());
var c=document.getElementById("table1").innerText.toString();
var oPopBody = oPopup.document.body;
oPopup.show(left,top, width, height, document.body);
oPopup.document.open;
//让oPopup在鼠标离开时自动隐藏。
oPopup.document.write("<body leftmargin=0 topmargin=0 scroll=no style='border : 0 px;bgColor:#cccccc' onmouseover=clearTimeout(parent.popt); onmouseout=parent.popt=setTimeout('parent.oPopup.hide()',10);>");//用document.write()写菜单内容
oPopup.document.write("<table width=100% height=100% style='border-collapse : collapse;'>");
for(var i=0;i<MenuText[t].length;i++)
{
oPopup.document.write("<tr><td background='image/topbg.gif' bgcolor=#cccccc style='border-top : #cccccc 1px solid;border-bottom : #666666 1px solid;border-left : #cccccc 1px solid;border-right : #666666 1px solid;mouse : hand; font-size : 12px; color:#000000;text-align : left;vertical-align : center;CURSOR: hand' onmouseover=this.bgColor='#C2D2E5'; onmouseout=this.bgColor='#cccccc'; height='20' onclick='parent.parent.main.location.href=\""+MenuEven[t][i]+"\"';>"+MenuText[t][i]+"</td></tr>");
}
oPopup.document.write("</table></td></tr></table>");
//alert("nnnnn")
//oPopup.document.write("<table>");
//oPopup.document.write(b);
//oPopup.document.write("<tr><td>3333</td></tr>");
//oPopup.document.write("</table>");
// alert("mmmm")
oPopup.document.write("</body>")
}</script>
</HEAD><BODY>
<table>
<tr>
<td align="left" onclick="ButtonClick(this,1)">菜单1</td>
</tr>
<br>
<tr>
<td height="200">
</td>
</tr>
<br>
</table>
<table id="table1">
<tr>
<td align="left" >菜单3</td>
</tr>
<br>
<tr>
<td align="left" style="color:red" >菜单4</td>
<br></BODY>
</HTML>