<script type="text/javascript"> function printPage() { var innerContent=document.body.innerHTML; alert(innerContent); var newWin =window.open("about:blank","print"); newWin.document.write(innerContent); } </script>
1.假设当前页面为a.html,var aHtml = document.body.innerHTML; 跳转到b.html后,在b中通过window.opener.document.aHtml来访问 //若此时a页面已关闭,window.opener会为null,这时可以用下面几种方法 2.弄个隐藏域,Post过去 3.JS在当前页面将值写入cookie,在另一页面获取 4. 用showModalDialog 用法如下: vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures]) 父窗口向子窗口 传入参数: 要想对话框传递参数,是通过vArguments来进行传递的。类型不限制,对于字符串类型,最大为4096个字符。也可以传递对象,例如: test1.htm ==================== <script> var mxh1 = new Array( "mxh ", "net_lover ", "孟子E章 ") var mxh2 = window.open( "about:blank ", "window_mxh ") // 向对话框传递数组 window.showModalDialog( "test2.htm ",mxh1) // 向对话框传递window对象 window.showModalDialog( "test3.htm ",mxh2) </script> test2.htm ==================== <script> var a = window.dialogArguments alert( "您传递的参数为: " + a) </script> test3.htm ==================== <script> var a = window.dialogArguments alert( "您传递的参数为window对象,名称: " + a.name) </script>
function printPage()
{
var innerContent=document.body.innerHTML;
alert(innerContent);
var newWin =window.open("about:blank","print");
newWin.document.write(innerContent);
}
</script>
跳转到b.html后,在b中通过window.opener.document.aHtml来访问 //若此时a页面已关闭,window.opener会为null,这时可以用下面几种方法
2.弄个隐藏域,Post过去
3.JS在当前页面将值写入cookie,在另一页面获取
4. 用showModalDialog
用法如下:
vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures]) 父窗口向子窗口 传入参数:
要想对话框传递参数,是通过vArguments来进行传递的。类型不限制,对于字符串类型,最大为4096个字符。也可以传递对象,例如: test1.htm
====================
<script>
var mxh1 = new Array( "mxh ", "net_lover ", "孟子E章 ")
var mxh2 = window.open( "about:blank ", "window_mxh ")
// 向对话框传递数组
window.showModalDialog( "test2.htm ",mxh1)
// 向对话框传递window对象
window.showModalDialog( "test3.htm ",mxh2)
</script> test2.htm
====================
<script>
var a = window.dialogArguments
alert( "您传递的参数为: " + a)
</script> test3.htm
====================
<script>
var a = window.dialogArguments
alert( "您传递的参数为window对象,名称: " + a.name)
</script>
function printPage()
{
var innerContent=document.body.innerHTML;
var newWin =window.open("b.aspx","print");
newWin.document.getElementById("div1").innerHTML = innerContent;
}
</script>
慕白兄 ,运行到
newWin.document.getElementById("div1").innerHTML = innerContent;
这一句的时候 出错了啊?