js打印,横向就显示不完整了

-一个大坑 2017-09-01 10:55:24

bdhtml = window.document.body.innerHTML;
sprnstr = "<!--startprint-->";
eprnstr = "<!--endprint-->";
prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
window.document.body.innerHTML = prnhtml;
window.print();

网上找的js打印,我留的备注栏(空的)剩下特别小


$(function () {
$("#btnPrint").click(function () {
$.ajax({
url: '/SCRP0101/GetPrint?driverName=' + $("#driverName").val(),
type: "GET",
data: {},
success: function (data) {
$("#disposeDiv").empty().append(data);
layer.open({
type: 1,
content: $("#disposeDiv"),
shade: 0.3,
resize: true,
area: 'auto,auto',
btn: ["打印", "取消"],
yes: function (index, layro) {
bdhtml = window.document.body.innerHTML;
sprnstr = "<!--startprint-->";
eprnstr = "<!--endprint-->";
prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
window.document.body.innerHTML = prnhtml;
window.print();
layer.closeAll();
return false;
},
btn2: function (index, layro) {
layer.closeAll();
return false;
}
});
},
error: function (msg) {
alert('失败了,可能后台报错');
},
});
})
});
...全文
1222 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
-一个大坑 2017-09-25
  • 打赏
  • 举报
回复
引用 11 楼 u013116426 的回复:
[quote=引用 9 楼 happy4944 的回复:] [quote=引用 8 楼 u013116426 的回复:] 例如@item.PASSENGER_QTY
在td里加scritp识别不了[/quote] 哎呀! 那你别再数据里面加换行了,直接在html里加吧![/quote] http://bbs.csdn.net/topics/392268136 帮我看下这个,谢谢
-一个大坑 2017-09-05
  • 打赏
  • 举报
回复
引用 11 楼 u013116426 的回复:
[quote=引用 9 楼 happy4944 的回复:] [quote=引用 8 楼 u013116426 的回复:] 例如@item.PASSENGER_QTY
在td里加scritp识别不了[/quote] 哎呀! 那你别再数据里面加换行了,直接在html里加吧![/quote] 我用;隔开,不想改了
-一个大坑 2017-09-05
  • 打赏
  • 举报
回复
引用 11 楼 u013116426 的回复:
[quote=引用 9 楼 happy4944 的回复:] [quote=引用 8 楼 u013116426 的回复:] 例如@item.PASSENGER_QTY
在td里加scritp识别不了[/quote] 哎呀! 那你别再数据里面加换行了,直接在html里加吧![/quote] http://bbs.csdn.net/topics/392258280?page=1#post-402711518 帮我看下这个,js接收返回值,用$("#disposeDiv").empty().append(data);就会打开页面
___紫菜 2017-09-04
  • 打赏
  • 举报
回复
引用 4 楼 happy4944 的回复:
[quote=引用 3 楼 u013116426 的回复:] 试试escape()
周末休息,没看论坛。用list返回接收的值,不知道怎么套上escape() [/quote] 你怎么绑定显示的。
-一个大坑 2017-09-04
  • 打赏
  • 举报
回复
引用 3 楼 u013116426 的回复:
试试escape()
周末休息,没看论坛。用list返回接收的值,不知道怎么套上escape()
___紫菜 2017-09-04
  • 打赏
  • 举报
回复
引用 9 楼 happy4944 的回复:
[quote=引用 8 楼 u013116426 的回复:] 例如@item.PASSENGER_QTY
在td里加scritp识别不了[/quote] 哎呀! 那你别再数据里面加换行了,直接在html里加吧!
-一个大坑 2017-09-04
  • 打赏
  • 举报
回复
引用 8 楼 u013116426 的回复:
[quote=引用 6 楼 happy4944 的回复:] [quote=引用 5 楼 u013116426 的回复:] [quote=引用 4 楼 happy4944 的回复:] [quote=引用 3 楼 u013116426 的回复:] 试试escape()
周末休息,没看论坛。用list返回接收的值,不知道怎么套上escape() [/quote] 你怎么绑定显示的。[/quote]

    <table class="table table-bordered table-hover table-condensed table-responsive">
        <thead>
            <tr><th colspan="12" style="text-align: center; height: 50px"><h4>随车单</h4></th></tr>
            <tr>
                <th>單號</th>
                <th width="85x">用車日期</th>
                <th width="50px">乘車人數</th>
                <th width="120px">用車時間</th>
                <th>申請人</th>
                <th width="50px">用車对象</th>
                <th width="200px">乘客信息</th>
                <th width="200px">行程</th>
                <th>車牌</th>
                <th width="50px">司機</th>
                <th width="100px">乘車人簽名</th>
                <th width="50px">實際人數</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in daysSendCar)
            {
                <tr>
                    <td>@item.APPNO</td>
                    <td>@string.Format("{0:yyyy-MM-dd}", item.APPDT)</td>
                    <td><script>unescape(@item.PASSENGER_QTY)</script></td>
                    <td>@item.RIDE_STARTTIME</td>
                    <td>@item.APPEMPLNAME</td>
                    <td>@item.GROUPNAME</td>
                    <td>@item.PNAME</td>
                    <td>@item.ADDFROM</td>
                    <td>@item.CARNO</td>
                    <td>@item.DRIVERNAME</td>
                    <td></td>
                    <td>222 <br> 222</td>  **这个换行有效果
                </tr>
            }
            <tr><td colspan="12">停車費用</td></tr>
        </tbody>
    </table>
[/quote]
引用 6 楼 happy4944 的回复:
[quote=引用 5 楼 u013116426 的回复:] [quote=引用 4 楼 happy4944 的回复:] [quote=引用 3 楼 u013116426 的回复:] 试试escape()
周末休息,没看论坛。用list返回接收的值,不知道怎么套上escape() [/quote] 你怎么绑定显示的。[/quote]

    <table class="table table-bordered table-hover table-condensed table-responsive">
        <thead>
            <tr><th colspan="12" style="text-align: center; height: 50px"><h4>随车单</h4></th></tr>
            <tr>
                <th>單號</th>
                <th width="85x">用車日期</th>
                <th width="50px">乘車人數</th>
                <th width="120px">用車時間</th>
                <th>申請人</th>
                <th width="50px">用車对象</th>
                <th width="200px">乘客信息</th>
                <th width="200px">行程</th>
                <th>車牌</th>
                <th width="50px">司機</th>
                <th width="100px">乘車人簽名</th>
                <th width="50px">實際人數</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in daysSendCar)
            {
                <tr>
                    <td>@item.APPNO</td>
                    <td>@string.Format("{0:yyyy-MM-dd}", item.APPDT)</td>
                    <td> <scritp>unescape(@item.PASSENGER_QTY)</script></td>
                    <td>@item.RIDE_STARTTIME</td>
                    <td>@item.APPEMPLNAME</td>
                    <td>@item.GROUPNAME</td>
                    <td>@item.PNAME</td>
                    <td>@item.ADDFROM</td>
                    <td>@item.CARNO</td>
                    <td>@item.DRIVERNAME</td>
                    <td></td>
                    <td>222 <br> 222</td>  **这个换行有效果
                </tr>
            }
            <tr><td colspan="12">停車費用</td></tr>
        </tbody>
    </table>
[/quote] 例如@item.PASSENGER_QTY[/quote] http://bbs.csdn.net/topics/392258292 结贴了,我又从新开了个贴
-一个大坑 2017-09-04
  • 打赏
  • 举报
回复
引用 8 楼 u013116426 的回复:
例如@item.PASSENGER_QTY


在td里加scritp识别不了
___紫菜 2017-09-04
  • 打赏
  • 举报
回复
引用 6 楼 happy4944 的回复:
[quote=引用 5 楼 u013116426 的回复:] [quote=引用 4 楼 happy4944 的回复:] [quote=引用 3 楼 u013116426 的回复:] 试试escape()
周末休息,没看论坛。用list返回接收的值,不知道怎么套上escape() [/quote] 你怎么绑定显示的。[/quote]

    <table class="table table-bordered table-hover table-condensed table-responsive">
        <thead>
            <tr><th colspan="12" style="text-align: center; height: 50px"><h4>随车单</h4></th></tr>
            <tr>
                <th>單號</th>
                <th width="85x">用車日期</th>
                <th width="50px">乘車人數</th>
                <th width="120px">用車時間</th>
                <th>申請人</th>
                <th width="50px">用車对象</th>
                <th width="200px">乘客信息</th>
                <th width="200px">行程</th>
                <th>車牌</th>
                <th width="50px">司機</th>
                <th width="100px">乘車人簽名</th>
                <th width="50px">實際人數</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in daysSendCar)
            {
                <tr>
                    <td>@item.APPNO</td>
                    <td>@string.Format("{0:yyyy-MM-dd}", item.APPDT)</td>
                    <td><script>unescape(@item.PASSENGER_QTY)</script></td>
                    <td>@item.RIDE_STARTTIME</td>
                    <td>@item.APPEMPLNAME</td>
                    <td>@item.GROUPNAME</td>
                    <td>@item.PNAME</td>
                    <td>@item.ADDFROM</td>
                    <td>@item.CARNO</td>
                    <td>@item.DRIVERNAME</td>
                    <td></td>
                    <td>222 <br> 222</td>  **这个换行有效果
                </tr>
            }
            <tr><td colspan="12">停車費用</td></tr>
        </tbody>
    </table>
[/quote]
引用 6 楼 happy4944 的回复:
[quote=引用 5 楼 u013116426 的回复:] [quote=引用 4 楼 happy4944 的回复:] [quote=引用 3 楼 u013116426 的回复:] 试试escape()
周末休息,没看论坛。用list返回接收的值,不知道怎么套上escape() [/quote] 你怎么绑定显示的。[/quote]

    <table class="table table-bordered table-hover table-condensed table-responsive">
        <thead>
            <tr><th colspan="12" style="text-align: center; height: 50px"><h4>随车单</h4></th></tr>
            <tr>
                <th>單號</th>
                <th width="85x">用車日期</th>
                <th width="50px">乘車人數</th>
                <th width="120px">用車時間</th>
                <th>申請人</th>
                <th width="50px">用車对象</th>
                <th width="200px">乘客信息</th>
                <th width="200px">行程</th>
                <th>車牌</th>
                <th width="50px">司機</th>
                <th width="100px">乘車人簽名</th>
                <th width="50px">實際人數</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in daysSendCar)
            {
                <tr>
                    <td>@item.APPNO</td>
                    <td>@string.Format("{0:yyyy-MM-dd}", item.APPDT)</td>
                    <td> <scritp>unescape(@item.PASSENGER_QTY)</script></td>
                    <td>@item.RIDE_STARTTIME</td>
                    <td>@item.APPEMPLNAME</td>
                    <td>@item.GROUPNAME</td>
                    <td>@item.PNAME</td>
                    <td>@item.ADDFROM</td>
                    <td>@item.CARNO</td>
                    <td>@item.DRIVERNAME</td>
                    <td></td>
                    <td>222 <br> 222</td>  **这个换行有效果
                </tr>
            }
            <tr><td colspan="12">停車費用</td></tr>
        </tbody>
    </table>
[/quote] 例如@item.PASSENGER_QTY
___紫菜 2017-09-04
  • 打赏
  • 举报
回复
引用 6 楼 happy4944 的回复:
[quote=引用 5 楼 u013116426 的回复:] [quote=引用 4 楼 happy4944 的回复:] [quote=引用 3 楼 u013116426 的回复:] 试试escape()
周末休息,没看论坛。用list返回接收的值,不知道怎么套上escape() [/quote] 你怎么绑定显示的。[/quote]

    <table class="table table-bordered table-hover table-condensed table-responsive">
        <thead>
            <tr><th colspan="12" style="text-align: center; height: 50px"><h4>随车单</h4></th></tr>
            <tr>
                <th>單號</th>
                <th width="85x">用車日期</th>
                <th width="50px">乘車人數</th>
                <th width="120px">用車時間</th>
                <th>申請人</th>
                <th width="50px">用車对象</th>
                <th width="200px">乘客信息</th>
                <th width="200px">行程</th>
                <th>車牌</th>
                <th width="50px">司機</th>
                <th width="100px">乘車人簽名</th>
                <th width="50px">實際人數</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in daysSendCar)
            {
                <tr>
                    <td>@item.APPNO</td>
                    <td>@string.Format("{0:yyyy-MM-dd}", item.APPDT)</td>
                    <td>@item.PASSENGER_QTY</td>
                    <td>@item.RIDE_STARTTIME</td>
                    <td>@item.APPEMPLNAME</td>
                    <td>@item.GROUPNAME</td>
                    <td>@item.PNAME</td>
                    <td>@item.ADDFROM</td>
                    <td>@item.CARNO</td>
                    <td>@item.DRIVERNAME</td>
                    <td></td>
                    <td>222 <br> 222</td>  **这个换行有效果
                </tr>
            }
            <tr><td colspan="12">停車費用</td></tr>
        </tbody>
    </table>
[/quote] csdnshiSB
-一个大坑 2017-09-04
  • 打赏
  • 举报
回复
引用 5 楼 u013116426 的回复:
[quote=引用 4 楼 happy4944 的回复:] [quote=引用 3 楼 u013116426 的回复:] 试试escape()
周末休息,没看论坛。用list返回接收的值,不知道怎么套上escape() [/quote] 你怎么绑定显示的。[/quote]

    <table class="table table-bordered table-hover table-condensed table-responsive">
        <thead>
            <tr><th colspan="12" style="text-align: center; height: 50px"><h4>随车单</h4></th></tr>
            <tr>
                <th>單號</th>
                <th width="85x">用車日期</th>
                <th width="50px">乘車人數</th>
                <th width="120px">用車時間</th>
                <th>申請人</th>
                <th width="50px">用車对象</th>
                <th width="200px">乘客信息</th>
                <th width="200px">行程</th>
                <th>車牌</th>
                <th width="50px">司機</th>
                <th width="100px">乘車人簽名</th>
                <th width="50px">實際人數</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in daysSendCar)
            {
                <tr>
                    <td>@item.APPNO</td>
                    <td>@string.Format("{0:yyyy-MM-dd}", item.APPDT)</td>
                    <td>@item.PASSENGER_QTY</td>
                    <td>@item.RIDE_STARTTIME</td>
                    <td>@item.APPEMPLNAME</td>
                    <td>@item.GROUPNAME</td>
                    <td>@item.PNAME</td>
                    <td>@item.ADDFROM</td>
                    <td>@item.CARNO</td>
                    <td>@item.DRIVERNAME</td>
                    <td></td>
                    <td>222 <br> 222</td>  **这个换行有效果
                </tr>
            }
            <tr><td colspan="12">停車費用</td></tr>
        </tbody>
    </table>
-一个大坑 2017-09-01
  • 打赏
  • 举报
回复
引用 1 楼 happy4944 的回复:
我加的</br>直接在table上显示出来,而没有换行
我直接在td加<br>可以换行,后台带的<br>就直接显示,不换行
-一个大坑 2017-09-01
  • 打赏
  • 举报
回复

我加的</br>直接在table上显示出来,而没有换行
___紫菜 2017-09-01
  • 打赏
  • 举报
回复
试试escape()

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧