当有人尝试打印页面时,我需要破坏jQueryUI选项卡。
我无法使用CSS隐藏它,因为我需要这些标签中的数据。

有人可以帮助/指出正确的方向吗?
也许还有其他方法可以达到相同的结果?

摧毁我的意思是:

$('#tabs').tabs("destroy");


它必须在IE7 / 8上工作,因为该浏览器是公司使用的浏览器。

解决方案(感谢@Phil):

//Destroys the tabs for print
window.onbeforeprint = destroyTabs;

//Remakes tabs after printing
window.onafterprint = makeTabs;


function makeTabs() {
    $('#tabs').tabs();
}

function destroyTabs() {
    $('#tabs').tabs('destroy');
}

最佳答案

这可能起作用:

@media print {
    .ui-tabs-nav { display: none; }
    .ui-tabs .ui-tabs-hide { display: block !important; }
}




这是黑暗中的另一枪(我没有尝试过),但是:

<script type="text/javascript">
     window.onbeforeprint = destroyTabs;

     function destroyTabs(){
       $('#tabs').tabs('destroy').tabs();
     }
</script>

关于javascript - 按下ctrl + p时触发JavaScript函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11349129/

10-09 20:03
查看更多