function preview()
{
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.document.body.style.backgroundColor = '#ffffff';
window.document.body.style.color = '#000000';
window.print();
}
function print(){
if(confirm('是否打印该页面!')){
var o=document.getElementById("noprint")
for(var i=0;i<0.length;i++){
o.style.display="none";//隐藏不需要打印部分
}
window.print()
}
else{
window.history.back(-1);
//或 window.location.href='上页.asp';
}<style type="text/css">
.style1
{
width: 100%;
}
</style>
</head>
<body>
<table class="style1">
<tr>
<td>
内容1</td>
<td>
内容2</td>
</tr>
<tr>
<td>
内容3</td>
<td>
内容4</td>
</tr>
</table>
<form id="form1" runat="server">
<div id="noprint">
<input id="Button5" type="button" value="打印" onclick="javascript:if(confirm('是否打印该页面!')){window.print()}"/>
</div>
</form>
</body>
</html>我的代码如上,可是还是把那个按钮打印出来了
解决方案 »
- 三层架构研究
- 询问下一个数据设计思路问题,重在参与
- div id问题请教
- 昨天很郁闷的,今天来散分,顺便问个问题
- 怎样在vista上安装asp.net 网站呢?
- 知道农历如何转换为阳历,有这方面的函数吗?
- 请教执行ListBox的SelectedIndexChanged的时候的问题
- select (cInvStd+cinvname) as cinvname from inventory
- 调用Server.MachineName属性需要引用什么命名空间?
- 输入类似<td>dfdfddf</td>符号可以存进数据库,但读出后显示在table中会有问题!
- dropdownlist联动问题
- 大牛帮忙解释下代码, 接口继承重写.
@media print
{
.notprint
{
display: none;
}
}
<style media=print type="text/css">
.Noprint{display:none;}
</style><input type="button" value="打印" class="Noprint">
一、@import
<style type="text/css" media="screen">
@import url("example.css");
</style>
二、link
<link rel="stylesheet" rev="stylesheet" href="example.css" type="text/css" media="all" />
link与@import的区别
这两种方式都是为了加载CSS文件,但还是存在着细微的差别。 差别1:老祖宗的差 别。link属于XHTML标签,而@import完全是CSS提供的一种方式。@import 可以写在css文件内,用于引入另外的css文件,格式为:@import url("example.css")screen[, print[,...]];
link标签除了可以加载CSS外,还可以做很多其它的事 情,比如定义RSS,定义rel连接属性等,@import就只能加载CSS了。 差别2:加载顺序的差别。当一个页面被加载的时候 (就是被浏览者浏览的时候),link引用的CSS会同时被加载,而@import引用的CSS 会等到页面全部被下载完再被加载。所以有时候浏览 @import加载CSS的页面时开始会没有样式(就是闪烁),网速慢的时候还挺明显(梦之都加载CSS 的方式就是使用@import,我一边下载一边 浏览梦之都网页时,就会出现上述问题)。 差别3:兼容性的差别。由于@import是CSS2.1提出的所以老的浏览器不支 持,@import只有在IE5以上的才能识别,而link标签无此问题。 差别4:使用dom控制样式时的差别。当使用 javascript控制dom去改变样式的时候,只能使用link标签,因为@import不是dom可以控制的。
CSS Media属性
screen:指计算机屏幕。
print:指用于打印机的不透明介质。
projection:指用于显示的项目。
braille:盲文系统,指有触觉效果的印刷品。
aural:指语音电子合成器。
tv:指电视类型的媒体。
handheld:指手持式显示设备(小屏幕,单色)
all:适合于所有媒体。