js 如何在网页另存为 .txt格式的文件

JavaScript024

js 如何在网页另存为 .txt格式的文件,第1张

单击文件菜单下的另存为就会弹出一个另存为对话框,这时再在保存类型下选择.txt类型,这样就可以把整个网页保存下来,至于你说的内容不乱,这个我不太清楚.不过只要你再在.txt文件里修改一下就行了,或者你将你要的内容复制到word里面就行了.

2种形式:

第一种:

<script>

function SaveAs5(imgURL)

{

var oPop = window.open(imgURL,"","width=1, height=1, top=5000, left=5000")

for(oPop.document.readyState != "complete")

{

if (oPop.document.readyState == "complete")break

}

oPop.document.execCommand("SaveAs")

oPop.close()

}

</script>

<img src="t_screenshot_17616.jpg" id="DemoImg" border="0" onclick="SaveAs5(this.src)">

第二种:

<script>

function SaveAs5(imgURL)

{

var oPop = window.open(imgURL,"","width=1, height=1, top=5000, left=5000")

for(oPop.document.readyState != "complete")

{

if (oPop.document.readyState == "complete")break

}

oPop.document.execCommand("SaveAs")

oPop.close()

}

</script>

<img src="../t_screenshot_17616.jpg" id="DemoImg" border="0">

<a href="#" onclick="SaveAs5(document.getElementById('DemoImg').src)">点击这里下载图片 </a>