<script language="javascript">
//读文件
function readFile(filename) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile(filename, 1);
var s = "";
while (!f.AtEndOfStream)
s += f.ReadLine() + "\n";
f.Close();
return s;
}
//读文件夹
function readDir() {
var savePath;
var objSrc = new ActiveXObject("Shell.Application").BrowseForFolder(0, '请选择文件目录:', 0, '');
//BrowseForFolder(0, Message, 0x0040, 0x11); //起始目录为:我的电脑 Shell.BrowseForFolder(0,Message,0); //起始目录为:桌面
if (objSrc != null) {
savePath = objSrc.Self.Path; // objSrc.Items().Path;
//document.all.savePath.value = savePath;
}
}
</script>
有确定和取消功能的弹出框 comfirm(“提示信息”);
var mes=confirm("您确定要**吗?");
if(mes==true){ do sth; }
else{ do otherthings; }
test1.htm
====================
<script>
var mxh1 = new Array("mxh","net_lover","
孟子
E
章
")
var mxh2 = window.open("about:blank","window_mxh")
//
向对话框传递数组
window.showModalDialog("test2.htm",mxh1)
//
向对话框传递
window
对象
window.showModalDialog("test3.htm",mxh2)
</script>
test2.htm ====================
<script>
var a = window.dialogArguments
alert("
您传递的参数为:
" + a)
</script>
test3.htm ====================
<script>
var a = window.dialogArguments
alert("
您传递的参数为
window
对象,名称:
" + a.name)
</script>
可以通过 window.returnValue 向打开对话框的窗口返回信息,当然也可以是对象。例如: test4.htm ===================
<script>
var a = window.showModalDialog("test5.htm")
for (i = 0; i < a.length; i++) alert(a[i])
</script>
test5.htm ===================
<script>
function sendTo() {
var a = new Array("a", "b")
window.returnValue = a
window.close()
}
</script>
<body>
<form>
<input value="
返回
" type="button">
</form>