现在的位置: 首页 > 综合 > 正文

网页JS代码:保存本页 打印本页 关闭本页

2017年11月28日 ⁄ 综合 ⁄ 共 695字 ⁄ 字号 评论关闭

网页JS代码:保存本页 打印本页 关闭本页

 

<html>
<head>
<script language="JavaScript">

//保存本页代码共3处
// script 脚本放到 head
//body onLoad="isReady=true"
//<a
href="javascript:doSaveAs()">保存本页</a>
var isReady =
false;
function doSaveAs(){
if (document.execCommand){
if
(isReady){document.execCommand("SaveAs");}
}else{
alert('Feature available
only in Internet Exlorer 4.0 and
later.');
}
}
</script>
</head>
<body
onLoad="isReady=true">
<!--//保存本页代码共3处
// script 脚本放到 head
//body
onLoad="isReady=true"
//<a
href="javascript:doSaveAs()">保存本页</a>
-->
<a
href="javascript:doSaveAs()">保存本页</a>
<a onclick=window.print()
style="cursor:hand">打印本页页</a> 
<a onclick="window.opener=null"
href="javascript:window.close()">关闭本页</a>

</body>

 

保存也可以这样:document.execCommand("SaveAs",filename);

抱歉!评论已关闭.