【问题标题】:Add button to print table to printer in bonfire codeigniter在篝火codeigniter中添加按钮以将表格打印到打印机
【发布时间】:2016-08-08 02:51:59
【问题描述】:

我是 codeigniter 和 bonfire 的新手,对此我很陌生,但我想知道如何添加按钮以将我的表格打印到打印机或 pdf 文件。我尝试使用window.print(),它可以工作,但它没有加载 css 或表格的样式。我知道我必须在 javascript 中加载 css 文件,然后我使用此代码:

function printContent(id){
str=document.getElementById(id).innerHTML
newwin=window.open('','printwin','left=100,top=100,width=400,height=400')
newwin.document.write('<HTML>\n<HEAD>\n')
newwin.document.write('<TITLE>Print Page</TITLE>\n')
newwin.document.write('<script>\n')
newwin.document.write('function chkstate(){\n')
newwin.document.write('if(document.readyState=="complete"){\n')
newwin.document.write('window.close()\n')
newwin.document.write('}\n')
newwin.document.write('else{\n')
newwin.document.write('setTimeout("chkstate()",2000)\n')
newwin.document.write('}\n')
newwin.document.write('}\n')
newwin.document.write('function print_win(){\n')
newwin.document.write('window.print();\n')
newwin.document.write('chkstate();\n')
newwin.document.write('}\n')
newwin.document.write('<\/script>\n')
newwin.document.write('</HEAD>\n')
newwin.document.write('<BODY onload="print_win()">\n')
newwin.document.write(str)
newwin.document.write('</BODY>\n')
newwin.document.write('</HTML>\n')
newwin.document.close()
}

但我不知道 bonfire 将我必须包含的 css 文件存储在哪里,我尝试包含此 newwin.document.write('&lt;?php echo Assets::css; ?&gt;\n'),它根本不起作用,谁能帮助我?

【问题讨论】:

    标签: javascript php css printing


    【解决方案1】:

    为此,您必须在 Bonfire 中加载您的 js,您可以添加您的 js
    路径:-public\themes\default\header.php

    这里是你需要添加你的js的文件。

    Assets::add_js('bootstrap.min.js','your_js_file');
    

    如果您遇到任何问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-19
      • 2019-07-22
      • 1970-01-01
      • 2013-10-13
      相关资源
      最近更新 更多