javascript 打印预览的实现
引自:http://blog.csdn.net/lsj19830812/archive/2007/10/25/1843578.aspx
a.jsp是要打印的页面
<html>
<head>
<script language="javascript">
function fmtPrint(printPlace,w,h){
var sarg=new Array();
var sdata=document.all.item(printPlace);
sarg[0]=sdata.outerHTML;
window.showModalDialog("print.jsp",sarg,"dialogWidth:"+w+"px;dialogHeight:"+h+"px;center:yes;help:no;status:no;resizable:yes");
return;
}
</script>
</head>
<body>
<div id="printPlace">
希望打印的内容写在里面
...........
...........
...........
...........
...........
</div>
<img onClick="fmtPrint('printPlace', 800, 600);" name="Print" border="0" style="cursor:hand" src="images/dayin.gif">
</body>
</html>
print.jsp是打印预览页面
<html>
<head>
<base target="_self">
<script language="javascript">
<!--
var dada = dialogArguments;
var da1 = dada[1];
function loaddatas(){
var tagBody;
var pf = document.all.item('printfield');
pf.insertAdjacentHTML('beforeEnd',da1);
var removeRadio = document.all.tags("input");
for(var i=0; i<removeRadio.length; i++){
tagBody = removeRadio[i];
if (tagBody.getAttribute("type") == "radio"||tagBody.getAttribute("type") == "checkbox")
{
tagBody.style.display = 'none';
}
}
var removeHref = document.all.tags("A");
for(var i=0; i<removeHref.length; i++){
tagBody = removeHref[i];
if (tagBody.getAttribute("href") != null)
{
tagBody.setAttribute("href","javascript:void(0)");
}
}
var removeImg = document.all.tags("img");
for(var i=0; i<removeImg.length; i++)
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional ......
唉,很久以前写的代码,晒一晒,估计自己看都看不懂了,:(
var head="display:''"
img_close=new Image()
img_close.src="/sysManage/images/f.gif"
img_open=new Image()
img_open.src="/sysManage/images/fo.gif"
img3=new Image()
img3.src="/sysManage/images/e.gif" ......
js验证表单大全
1. 长度限制
<script>
function test()
{
if(document.a.b.value.length>50)
{
alert("不能超过50个字符!");
document.a.b.focus();
return false;
}
}
</script>
<form name=a onsubmit="return test()">
<textarea name="b" cols="40" wrap="VIRTUAL" rows="6"&g ......
var a = document.getElementById("left");
var b = document.getElementById("right");
if(a.scrollHeight < b.scrollHeight)
{
a.style.height = b.scrollHeight+”px”;
} &nb ......