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++)
相关文档:
使用JavaScript 对Cookie 操作的封装
通过本篇,您能了解到:
匿名函数
闭包的产生
JavaScript实现private 以及 public 访问权限
document.cookie 的操作
Javascript 没有 private , public 访问权限设置的关键字,但是可以通过一定的技巧来模拟出相同的结果.
首先我们来看下面一行 ......
其实就是用me来代替this,不多说,看代码:
=============================
代码1:
<html>
<head>
<title>无标题文档</title>
</head>
<body>
<input id="testit" type=button value="测试" onclick="vbscript:me.value='完成'">
<input id="testit" type=button v ......
<div id="a1" style=" position:absolute; z-index:2;"></div>
<table width="200" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><img src="白羊.jpg" alt="hi.baidu.com/liwya" onmousemove ......
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 ......
转化为Boolean类型
所有JavaScript中的值都能隐式的转化为Boolean类型,比如:
0 == false; // true
1 == true; // true
'' == false // true
null == false // true
但是这些值都不是Boolean类型。
因此当我们使用三个等 ......