以下是我的这方面
的一些代码片段:
<script language = "javascript">
function OutFile()
{
var text = "sdfsd";
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition",
"attachment;" + " filename="+pid+".html");
response.getOutputStream().write(text.getBytes());
response.getOutputStream().flush();
}
function SaveAsOk()
{
document.execCommand("saveAs");
}
function WriteFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c://testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();
alert("
我已经在你的
C
盘根目录下生成了一个
testfile.txt
的文件!
");
}
function Split_rn()
{
//alert(split);
//substring("asdfs")
alert(document.getElementById("A005").value);
alert(document.getElementById("A005").value.split("/r/n")[0]);
alert(document.getElementById("A005").value.split("/r/n")[1]);
}
function docWrite_rn()
{
//alert(split);
//substring("asdfs")
var o_OK_value = document.getElementById("A005").value;
document.write("sdf");
document.write(" "+o_OK_value.split("/r/n")[0]+ "<br>");
document.write(o_OK_value.split("/r/n")[1]+ "<br>");
}
function JS_1()
{
var o_split = document.getElementById("A005").value.split("/r/n");
for (var i = 0; i < o_split.length;i++)
{
document.write("document.getElementById(/""+o_split[i]+"/").style.display=/"none/";");
document.write("<br>");
}
}
</script>
<input id="001" type="hidden" value="button" onclick="OutFile()"/>
<input id="002" type="hidden" value="button" onclick="SaveAsOk()"/>
<input id="003" type="hidden" value="WriteFile" onclick="WriteFile()"/>
<input id="004" type="hidden" value="Split" onclick="Split_rn()"/>
<input id="005" type="hidden" value="docWrite" onclick="docWrite_rn()"/>
<input id="006" type="button" value="docJS" onclick="JS_1()"/>
<textarea id="A005" type="text" style="height:200px;">
001
002
003
004
005
006</textarea>
不偷懒的话会陆续推出
~~~
:
)