应该可以吧,对当前页面的style进行循环,在createPopup中循环创建

解决方案 »

  1.   

    可以<!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">
    //初始化一个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>
    </BODY>
    </HTML>
      

  2.   

    var ss = pop.document.createStyleSheet();
    ss.addRule("div", "background-color: blue");  //自己加样式定义呀
      

  3.   

    但如果换成这样写的话就没有效果
    var ss = oPopup.document.createStyleSheet();
    ss.href="/CSS/EditorStyle.css";