javascript如何读取txt中的内容?

来源:百度知道 编辑:UC知道 时间:2024/06/27 05:40:16
javascript如何读取txt中的内容?
越简单越好!谢谢!

<body>
<script>
function onDone(txtData)
{
alert(txtData);
}
document.body.addBehavior("#default#download");
document.body.startDownload('test.txt',onDone);
</script>
</body>
要求IE5以上,且不能跨域访问test.txt

<form name=form1 method=post action="">
<input type=text name=text1><input type=sumbit value="提交" onclick="return f()">
</form>
<script>
function f()
{
alert(form1.text1.value);
return false;
}
</script>

document.all('txtId').value

document.getElementById("text1").value