如何在javascript中从execCommand()返回文件名和路径

如何在javascript中从execCommand()返回文件名和路径,javascript,html,Javascript,Html,我通过调用函数save_content_to_file(“hello world”,“C:\A.txt”)来调用上述代码。执行上述代码时,会打开一个SaveAs dailog框。用户可以遍历到任何目录并使用任何名称保存文件。我的问题是如何获取用户在保存文件时指定的目录路径和文件名。filename变量只包含“C:\A.txt”。我想返回用户指定的完整路径和文件名 提前谢谢。Yukti可能的重复 function save_content_to_file(content, filename){

我通过调用函数save_content_to_file(“hello world”,“C:\A.txt”)来调用上述代码。执行上述代码时,会打开一个SaveAs dailog框。用户可以遍历到任何目录并使用任何名称保存文件。我的问题是如何获取用户在保存文件时指定的目录路径和文件名。filename变量只包含“C:\A.txt”。我想返回用户指定的完整路径和文件名

提前谢谢。Yukti

可能的重复
function save_content_to_file(content, filename){
    var dlg = false;
    with(document){
        ir=createElement('iframe');
        ir.id='ifr';
        ir.location='about.blank';
        ir.style.display='none';
        body.appendChild(ir);
        with(getElementById('ifr').contentWindow.document){
            open("text/plain", "replace");
            charset = "utf-8";
            write(content);
            close();
            document.charset = "utf-8";
            dlg = execCommand('SaveAs', false, filename+'.txt');
        }
        body.removeChild(ir);
    }
    return dlg;
}