try:<script>
function doBar(flag){
if (flag==0){
document.all.t1.className="nobar" ;
document.all.t2.className="nobar" ;
}
if (flag==1){
document.all.t1.className="" ;
document.all.t2.className="" ;
}
}
</script><input type="text" name="t1" class=nobar value="文本1" >
<input type="text" name="t2" class=nobar value="文本2" >
<br>
<input type=button name=b1 value="没有边框" onclick="doBar('0');">
<input type=button name=b1 value="有边框" onclick="doBar('1');">
function doBar(flag){
if (flag==0){
document.all.t1.className="nobar" ;
document.all.t2.className="nobar" ;
}
if (flag==1){
document.all.t1.className="" ;
document.all.t2.className="" ;
}
}
</script><input type="text" name="t1" class=nobar value="文本1" >
<input type="text" name="t2" class=nobar value="文本2" >
<br>
<input type=button name=b1 value="没有边框" onclick="doBar('0');">
<input type=button name=b1 value="有边框" onclick="doBar('1');">
@media screen {
BODY {font-size:12pt;}
}
// When printed, the font size is 8pt.
@media print {
BODY {font-size:8pt;}
}
@media screen {
BODY {font-size:12pt;}
}
// When printed, the font size is 8pt.
@media print {
BODY {font-size:8pt;}
}
<input type="text" value="def">
那是不是这个写法只针对 input 可以,如果我要使 select\textarea
的边框在打印时不显示,也可以使用同样 方法呢?
<input type="text" value="def">
<select><option>hehe</select>
<textarea>hehe</textara>
但旁边的一个下拉按钮无法去掉.还有办法吗?
input,select,textarea {border:0pt;}
.hideSel{position:absolute;clip:rect(0,80,30,0)}
.hideSel2{position:absolute;clip:rect(0,40,30,0)}
}</style><div class=hideSel><select><option>需手动调rect</select></div>
<br>
<div class=hideSel2><select><option>hehe</select></div>
<style>@media print{
input,textarea {border:0pt;}
select{qswh:expression(this.outerHTML=this.innerText)}
}</style>
<script>
function window.onbeforeprint(){
var o=document.getElementsByTagName("select");
for(i=0;i<o.length;i++){o[i].outerHTML=o[i--].innerText}
}
</script>
<select><option>需手动调rect</select>
<select><option>hehe</select>
<style>@media print{
input,textarea {border:0pt;}
}</style>
<script>
function window.onbeforeprint(){
var o=document.getElementsByTagName("select");
for(i=0;i<o.length;i++){o[i].outerHTML=o[i--].innerText}
}
</script>
<input type="text" value="abc">
<select><option>hehe</select>
<input type="text" value="def">
<select><option>hehe</select>
<textarea>hehe</textara>
这样做还是有些问题:
1
对于select or textarea 在打印预览时是取消边框的
但当返回时,就无法恢复到select or textarea 的原样了,还是文本。
2
对于select中OPTION有多个值的情况,能否只显示当前被选中的那个。而不是
全部
在onafterprint中恢复边框!