上周将OA从2.75sp1升级到2.75sp2,问题随之而来,不知用友的人脑子又进了什么水,居然又修改打印功能(2.75升级到2.75sp1时已经害过一回了),而且发版说明根本没提及这项修改。这下好了,待发事项、已发事项里打印出来的表单字体都灰的(直接保留了input、select等控件于表单中,属性设为readonly、disabled造成的),真想妈X他们。又得自己动手了。
修改文件:printPreview.htm(前两次修改有说明)
修改内容:
在最靠近<body...的Javascript处添加一个函数,用来移除控件并保留内容,然后在BODY的onload事件中调用它。代码如下:
//
替换input等控件内容,只显示纯文本 --彭国辉 2008-01-22--
function ReplaceElementContent()
{
var main$ = document.getElementById( " mainBody " );
if ( ! main$) return ;
var obj = main$.getElementsByTagName( " INPUT " );
for (i = obj.length - 1 ; i >= 0 ; i -- )
{
if (obj[i].style.display == " none " || obj[i].style.visibility == " hidden " )
obj[i].removeNode( true );
else
{
if (obj[i].onpropertychange != null ) obj[i].onpropertychange = null ;
if (obj[i].type == " checkbox " )
{
if (obj[i].checked)
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099>√</font> " );
else
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099>×</font> " );
}
else if (obj[i].type == " text " )
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099> " + obj[i].value + " </font> " );
obj[i].removeNode( true );
}
}
obj = main$.getElementsByTagName( " SELECT " );
for (i = obj.length - 1 ; i >= 0 ; i -- )
{
if (obj[i].style.display != " none " && obj[i].style.visibility != " hidden " )
{
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099 size=2> " + obj[i].options[obj[i].selectedIndex].text + " </font> " );
}
obj[i].removeNode( true );
}
obj = main$.getElementsByTagName( " TEXTAREA " );
for (i = obj.length - 1 ; i >= 0 ; i -- )
{
if (obj[i].style.display != " none " && obj[i].style.visibility != " hidden " )
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099> " + obj[i].value.replace( / / g, " <br> " ) + " </font> " );
obj[i].removeNode( true );
}
}
function ReplaceElementContent()
{
var main$ = document.getElementById( " mainBody " );
if ( ! main$) return ;
var obj = main$.getElementsByTagName( " INPUT " );
for (i = obj.length - 1 ; i >= 0 ; i -- )
{
if (obj[i].style.display == " none " || obj[i].style.visibility == " hidden " )
obj[i].removeNode( true );
else
{
if (obj[i].onpropertychange != null ) obj[i].onpropertychange = null ;
if (obj[i].type == " checkbox " )
{
if (obj[i].checked)
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099>√</font> " );
else
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099>×</font> " );
}
else if (obj[i].type == " text " )
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099> " + obj[i].value + " </font> " );
obj[i].removeNode( true );
}
}
obj = main$.getElementsByTagName( " SELECT " );
for (i = obj.length - 1 ; i >= 0 ; i -- )
{
if (obj[i].style.display != " none " && obj[i].style.visibility != " hidden " )
{
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099 size=2> " + obj[i].options[obj[i].selectedIndex].text + " </font> " );
}
obj[i].removeNode( true );
}
obj = main$.getElementsByTagName( " TEXTAREA " );
for (i = obj.length - 1 ; i >= 0 ; i -- )
{
if (obj[i].style.display != " none " && obj[i].style.visibility != " hidden " )
obj[i].insertAdjacentHTML( " beforeBegin " , " <font color=#000099> " + obj[i].value.replace( / / g, " <br> " ) + " </font> " );
obj[i].removeNode( true );
}
}
PS:顺便修改嵌套内容的那个TABLE和DIV的宽度为100%(原为624),使内容超过624宽度时仍可打印完整。
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/6810355c2f78c12e91b7997a8e8c583a.gif)
此文仅作记录留存,谢绝转载、引用或评论!