关闭未使用脚本打开的文件 [英] Closing a File Not opened using Script

查看:55
本文介绍了关闭未使用脚本打开的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function CloseBrowser(){
openedWindow =window.open('','_self','');
openedWindow.close();


这是我用于通过单击按钮关闭浏览器的代码.它在chrome和IE上正常工作,但在FireFox中无法正常工作.我收到错误消息,提示无法关闭不是由脚本打开的文件.

我的C#应用​​程序正在使用
打开网页演示


here is the code i am using to close a browser with a button click .It works fine with chrome and IE but it fails to work in FireFox .I get error saying that cannot close a file that was not opened by a script.

My C# application is opening a webpage demo using

ProcessStartInfo startInfo;
startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Minimized;


startInfo.Arguments = aPath2 + "/demo.html";
Process.Start(startInfo.Arguments);


谁能帮我


can anyone help me

推荐答案

在您的Process.Start(startInfo.Arguments),

更改为:

In your Process.Start(startInfo.Arguments),

Change to:

Process proc = Process.Start(startInfo.Arguments);



然后,您可以稍后使用proc.Kill.如果您要在不同的线程中执行所有这些操作,则还可以获取proc.ProcessID.



Then you can use proc.Kill later on. You can also grab proc.ProcessID if you are doing all of this in different threads.


这篇关于关闭未使用脚本打开的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆