<form name=form1>
<input name=txt value="test.htm">
<input type=button value=另存为 onclick="mm(this.form.txt.value)">
</form><SCRIPT LANGUAGE="JavaScript"><!--
function mm(str)
{
if(!str) return;
var w = window.open(str, "_blank", "width=100, height=100");
w.document.execCommand('SaveAs');
w.close();
}
//--></SCRIPT>
<input name=txt value="test.htm">
<input type=button value=另存为 onclick="mm(this.form.txt.value)">
</form><SCRIPT LANGUAGE="JavaScript"><!--
function mm(str)
{
if(!str) return;
var w = window.open(str, "_blank", "width=100, height=100");
w.document.execCommand('SaveAs');
w.close();
}
//--></SCRIPT>
应将test.htm设的尽可能小,width=0, height=0
她起一个跳板的作用
<input name=txt value="test.htm">
<input type=button value=另存为 onclick="mm(this.form.txt.value)">
</form><SCRIPT LANGUAGE="JavaScript"><!--
function mm(str)
{
if(!str) return;
this.document.execCommand('SaveAs');
}
//--></SCRIPT>
我把代码改了一下,就没有弹出窗口了,呵呵
我不想要选择保存路径的那个界面.该怎么办.我只想传文件名进去,然后保存,让用户感觉不到过程.(不是干坏事,是想把当前的网页转换成一封mime邮件)
<form name=form1>
<input name=txt value="tttt.htm">
<input type=button value=另存为 onclick="mm(document.form1.txt.value)">
</form>
<iframe width=0 height=0 frameborder=0 name=hrong style="display: none"></iframe><SCRIPT LANGUAGE="JavaScript"><!--
function mm(str)
{
if(!str) return;
window.frames["hrong"].location.href = str;
sa();
}
function sa()
{
if(window.frames["hrong"].document.readyState!="complete")
setTimeout("sa()", 100);
else
window.frames["hrong"].document.execCommand('SaveAs');
}
//--></SCRIPT>