当前位置:编程学习 > JS >>

网页另存为js代码

网页另存为二款js代码

其实很多时间我们都需要把网页的内容直接另存为,下面我们提供二款js另存为的网页代码吧。

<html>
<head>
<title>另存网页</title>
</head>
<body>
<object classid="clsid:8856f961-340a-11d0-a96b-00c04fd705a2"
height="0" width="0" id=webbrowser></object>
<input type="button" value="另存网页" onclick="webbrowser.execwb(4,1)">
</body>
</html>


方法二

<input type=button value=另存为 onclick=document.execcommand('saveas',false,'c:\test.htm')>


方法三

<input name=button onclick=document.all.webbrowser.execwb(4,1) type=button value=另存为><object classid=clsid:8856f961-340a-11d0-a96b-00c04fd705a2 height=0 id=webbrowser width=0></object>


看一款另存为的实例

//另存为指定文件或页面

function   savehtm(p_filename)  
{  
     var   winname   =   window.open('../upload/'+p_filename,   '_blank',   'top=10000');   
     winname.document.execcommand('saveas','',p_filename);
     winname.close();
}
//另存为当前页面
<input type=button value=另存为htm onclick="document.execcommand('saveas','true','xrx.htm')">
<p align="center"> 
<input type=button value=另存为txt onclick="document.execcommand('saveas','true','xrx.txt')"></p>
补充:网页制作,js教程 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,