我使用了一个日历控件calendar.js js 内容太长我只贴主要部分,需要的话我在跟贴
document.writeln('<div id="__calendarPanel" style="position:absolute;visibility:hidden;z-index:9999;background-color:#FFFFFF;border:1px solid #666666;width:200px;height:216px;">');
document.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="100%" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>');
var __ci = window.frames['__calendarIframe'];
__ci.document.writeln('<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">');

__ci.document.writeln('<html xmlns="http:\/\/www.w3.org\/1999\/xhtml">');
__ci.document.writeln('<head>');
__ci.document.writeln('<meta http-equiv="Content-Type" content="text\/html; charset=utf-8" \/>');
__ci.document.writeln('<title>Web Calendar(UTF-8) Written By KimSoft<\/title>');
__ci.document.writeln('<style type="text\/css">');
__ci.document.writeln('<!--');
__ci.document.writeln('body {font-size:12px;margin:0px;text-align:center;}');
__ci.document.writeln('form {margin:0px;}');
__ci.document.writeln('select {font-size:12px;background-color:#EFEFEF;}');
__ci.document.writeln('table {border:0px solid #CCCCCC;background-color:#FFFFFF}');
__ci.document.writeln('th {font-size:12px;font-weight:normal;background-color:#FFFFFF;}');
__ci.document.writeln('th.theader {font-weight:normal;background-color:#666666;color:#FFFFFF;width:24px;}');
__ci.document.writeln('select.year {width:64px;}');
__ci.document.writeln('select.month {width:60px;}');
__ci.document.writeln('td {font-size:12px;text-align:center;}');
__ci.document.writeln('td.sat {color:#0000FF;background-color:#EFEFEF;}');
__ci.document.writeln('td.sun {color:#FF0000;background-color:#EFEFEF;}');
__ci.document.writeln('td.normal {background-color:#EFEFEF;}');
__ci.document.writeln('input.l {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
__ci.document.writeln('input.r {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
__ci.document.writeln('input.b {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:100%;height:20px;}');
__ci.document.writeln('-->');
__ci.document.writeln('<\/style>');
__ci.document.writeln('<\/head>');
__ci.document.writeln('<body>');
__ci.document.writeln('<\/body>');
__ci.document.writeln('<\/html>');
__ci.document.close();
document.writeln('<\/div>');
var calendar = new Calendar();
//-->
在IE下正常使用,在火狐下报 
__ci is undefined
calendar.js()calendar.js (第 330 行)
[在此错误处中断] __ci.document.writeln('<!DOCTYPE html ...1\/DTD\/xhtml1-transitional.dtd">'); 
请高手指教啊

解决方案 »

  1.   

    上面代码中[color=#FF0000] 我想让它变色突出显示的,结果没变色....
      

  2.   

    '<!DOCTYPE html ...1\/DTD\/xhtml1-transitional.dtd">'
    是否是少了个"  
      

  3.   

    <script type="text/javascript">
                         document.writeln('<div id="__calendarPanel" style="position:absolute;visibility:hidden;z-index:9999;background-color:#FFFFFF;border:1px solid #666666;width:200px;height:216px;">');
    document.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="100%" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>');
    var __ci = window.frames['__calendarIframe'];
    __ci.document.open();
    __ci.document.writeln('<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">');
    __ci.document.writeln('<html xmlns="http:\/\/www.w3.org\/1999\/xhtml">');
    __ci.document.writeln('<head>');
    __ci.document.writeln('<meta http-equiv="Content-Type" content="text\/html; charset=utf-8" \/>');
    __ci.document.writeln('<title>Web Calendar(UTF-8) Written By KimSoft<\/title>');
    __ci.document.writeln('<style type="text\/css">');
    __ci.document.writeln('<!--');
    __ci.document.writeln('body {font-size:12px;margin:0px;text-align:center;}');
    __ci.document.writeln('form {margin:0px;}');
    __ci.document.writeln('select {font-size:12px;background-color:#EFEFEF;}');
    __ci.document.writeln('table {border:0px solid #CCCCCC;background-color:#FFFFFF}');
    __ci.document.writeln('th {font-size:12px;font-weight:normal;background-color:#FFFFFF;}');
    __ci.document.writeln('th.theader {font-weight:normal;background-color:#666666;color:#FFFFFF;width:24px;}');
    __ci.document.writeln('select.year {width:64px;}');
    __ci.document.writeln('select.month {width:60px;}');
    __ci.document.writeln('td {font-size:12px;text-align:center;}');
    __ci.document.writeln('td.sat {color:#0000FF;background-color:#EFEFEF;}');
    __ci.document.writeln('td.sun {color:#FF0000;background-color:#EFEFEF;}');
    __ci.document.writeln('td.normal {background-color:#EFEFEF;}');
    __ci.document.writeln('input.l {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
    __ci.document.writeln('input.r {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
    __ci.document.writeln('input.b {border: 1px solid #CCCCCC;background-color:#EFEFEF;width:100%;height:20px;}');
    __ci.document.writeln('-->');
    __ci.document.writeln('<\/style>');
    __ci.document.writeln('<\/head>');
    __ci.document.writeln('<body>');
    __ci.document.writeln('<\/body>');
    __ci.document.writeln('<\/html>');
    __ci.document.close();
    document.writeln('<\/div>');
    //-->        </script>
      

  4.   

     一样报错 __ci is undefined
    calendar.js()calendar.js (第 330 行)
    [在此错误处中断] __ci.document.open(); 
      

  5.   

    var __ci = window.frames['__calendarIframe'].contentWidnow;这样试试
      

  6.   

    FF 用 document.getelementById('__calendarIframe').contentWidnow;
      

  7.   

    顶楼上,还有一个延迟加载的问题,在执行document.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="100%" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>');时,会存在iframe还没加载完__ci.document.open();这句就执行了,所以FF下才会出现你说的__ci is undefined的问题。
    解决方案:实时刷新获取document.getelementById('__calendarIframe').contentWidnow,等有值时在执行下面的语句,自己想的,仅供参考。
    参考代码:<!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>
    <script type="text/javascript"> 
    document.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="100%" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>');
      window.setTimeout("play()",10);
      function play(){
       var      myWin   =   document.getElementById('__calendarIframe').contentWindow;
       alert(myWin);
                 // 写入html文件头
                myWin.document.write( " <html><head><title>test</title></head><body>hello</body></html> " );
                myWin.document.close();  // 关闭写入
              }
    </script>
    </head>
    <body>
    </body>
    </html>我不给它一个延迟执行在FF下会出现你说的情况
      

  8.   

    <!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=utf-8" />
    <title>无标题文档</title>
    </head><body>
    <script>
    document.writeln('<div id="__calendarPanel" style="position:absolute;z-index:9999;background-color:#FFFFFF;border:1px solid #666666;width:200px;height:216px;">');
    document.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="216" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>');
    var __ci = window.frames['__calendarIframe'];
    alert(__ci)
    __ci.document.writeln('<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">');
    __ci.document.writeln('<html xmlns="http:\/\/www.w3.org\/1999\/xhtml">');
    __ci.document.writeln('<head>');
    __ci.document.writeln('<meta http-equiv="Content-Type" content="text\/html; charset=utf-8" \/>');
    __ci.document.writeln('<title>Web Calendar(UTF-8) Written By KimSoft<\/title>');
    __ci.document.writeln('<style type="text\/css">');
    __ci.document.writeln('<!--');
    __ci.document.writeln('body{font-size:12px;margin:0px;text-align:center;}');
    __ci.document.writeln('form{margin:0px;}');
    __ci.document.writeln('select{font-size:12px;background-color:#EFEFEF;}');
    __ci.document.writeln('table{border:0px solid #CCCCCC;background-color:#FFFFFF}');
    __ci.document.writeln('th{font-size:12px;font-weight:normal;background-color:#FFFFFF;}');
    __ci.document.writeln('th.theader{font-weight:normal;background-color:#666666;color:#FFFFFF;width:24px;}');
    __ci.document.writeln('select.year{width:64px;}');
    __ci.document.writeln('select.month{width:60px;}');
    __ci.document.writeln('p{font-seize:100px;}');
    __ci.document.writeln('td{font-size:12px;text-align:center;}');
    __ci.document.writeln('td.sat{color:#0000FF;background-color:#EFEFEF;}');
    __ci.document.writeln('td.sun{color:#FF0000;background-color:#EFEFEF;}');
    __ci.document.writeln('td.normal{background-color:#EFEFEF;}');
    __ci.document.writeln('input.l{border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
    __ci.document.writeln('input.r{border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
    __ci.document.writeln('input.b{border: 1px solid #CCCCCC;background-color:#EFEFEF;width:100%;height:20px;}');
    __ci.document.writeln('-->');
    __ci.document.writeln('<\/style>');
    __ci.document.writeln('<\/head>');
    __ci.document.writeln('<body>');
    __ci.document.writeln('<p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<\/p>')
    __ci.document.writeln('<\/body>');
    __ci.document.writeln('<\/html>');
    __ci.document.close();
    document.writeln('<\/div>');
    //-->    </script>
    </body>
    </html>我试了 能出来~·楼主试试我这代码
      

  9.   

    好神奇,楼上的大神能给解释下不,我在公司的电脑运行楼主的代码结果__ci显示undefined,在家里的电脑上跟你说的一样可以显示
      

  10.   

     __calendarIframe是document.writeln进去的getElementById得不到
      

  11.   

    延迟的我是过,其实在得到frame之前弹个对话框就可以测试出来了,不行的
      

  12.   

     问题慢慢清晰了,把script写在body里是可以的,但是把script写在head里就不行了,请各位专家在帮忙研究研究
      

  13.   


    <!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=utf-8" />
    <title>无标题文档</title>
    <script>
        document.writeln('<div id="__calendarPanel" style="position:absolute;z-index:9999;background-color:#FFFFFF;border:1px solid #666666;width:200px;height:216px;">');
        document.writeln('<iframe name="__calendarIframe" id="__calendarIframe" width="100%" height="216" scrolling="no" frameborder="0" style="margin:0px;"><\/iframe>');
        var __ci = window.frames['__calendarIframe'];
        alert(__ci)
        __ci.document.writeln('<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">');
        __ci.document.writeln('<html xmlns="http:\/\/www.w3.org\/1999\/xhtml">');
        __ci.document.writeln('<head>');
        __ci.document.writeln('<meta http-equiv="Content-Type" content="text\/html; charset=utf-8" \/>');
        __ci.document.writeln('<title>Web Calendar(UTF-8) Written By KimSoft<\/title>');
        __ci.document.writeln('<style type="text\/css">');
        __ci.document.writeln('<!--');
        __ci.document.writeln('body{font-size:12px;margin:0px;text-align:center;}');
        __ci.document.writeln('form{margin:0px;}');
        __ci.document.writeln('select{font-size:12px;background-color:#EFEFEF;}');
        __ci.document.writeln('table{border:0px solid #CCCCCC;background-color:#FFFFFF}');
        __ci.document.writeln('th{font-size:12px;font-weight:normal;background-color:#FFFFFF;}');
        __ci.document.writeln('th.theader{font-weight:normal;background-color:#666666;color:#FFFFFF;width:24px;}');
        __ci.document.writeln('select.year{width:64px;}');
        __ci.document.writeln('select.month{width:60px;}');
        __ci.document.writeln('p{font-seize:100px;}');
        __ci.document.writeln('td{font-size:12px;text-align:center;}');
        __ci.document.writeln('td.sat{color:#0000FF;background-color:#EFEFEF;}');
        __ci.document.writeln('td.sun{color:#FF0000;background-color:#EFEFEF;}');
        __ci.document.writeln('td.normal{background-color:#EFEFEF;}');
        __ci.document.writeln('input.l{border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
        __ci.document.writeln('input.r{border: 1px solid #CCCCCC;background-color:#EFEFEF;width:20px;height:20px;}');
        __ci.document.writeln('input.b{border: 1px solid #CCCCCC;background-color:#EFEFEF;width:100%;height:20px;}');
        __ci.document.writeln('-->');
        __ci.document.writeln('<\/style>');
        __ci.document.writeln('<\/head>');
        __ci.document.writeln('<body>');
        __ci.document.writeln('<p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<\/p>')
        __ci.document.writeln('<\/body>');
        __ci.document.writeln('<\/html>');
        __ci.document.close();
        document.writeln('<\/div>');
        //-->    </script>
    </head><body>
        
    </body>
    </html>
    写head里也OK~·