我有一个 HTML 应用程序,我想保留在所有窗口的顶部(也就是说,如果打开/切换到另一个窗口,我希望这个窗口覆盖它)。JavaScript 解决方案在 Windows 7/IE9 模式下不起作用(不确定是什么阻碍了它,也无法更改),而 VBScript 解决方案似乎要么彻底失败,要么依赖外部组件。我也无法使用模式对话框,因为我需要将其置于所有其他窗口之上,而不仅仅是其父窗口之上。
并且不要将其标记为/sf/ask/1717753761/的重复项,因为(不幸的是仍然未回答)问题是指在其他窗口之上打开,而不是维护堆栈位置。
我尝试过的:
请记住,我无法下载额外的组件(没有 autoit 或 nircmd)。它应该全部集成到一个文件中,最好是 hta,但不是 zip。
仅对 Teemu 的解决方案进行了轻微修改,主要是为了可移植性(以防万一)。
<script language="javascript">
var locationstore = location.href
[...]
window.onload = function () {
var shell = new ActiveXObject('WScript.Shell'),
forceModal = function (e) {
shell.Run(locationstore, 1, 0);
};
top.addEventListener('blur', forceModal, false);
window.onbeforeunload = function () {
window.removeEventListener('blur', forceModal, false);
};
};
</script>
Run Code Online (Sandbox Code Playgroud) 我正在研究一个多线程项目,它有一个Thread可以抛出Error(而不是Exception)的情况.没有找到关于如何在多线程中处理错误的任何可靠信息,我决定做一些测试,发现结果可能不一致.
这是我的测试代码,以及评论结果.
public class MultiThreadError {
public static class ErrorThrowingRunnable implements Runnable{
private final boolean throwsError;
public ErrorThrowingRunnable(boolean throwsError){
this.throwsError = throwsError;
}
@Override
public void run() {
try {
// Wait between .5 and 1.5 seconds
Thread.sleep(500 + new Random().nextInt(1000));
} catch (InterruptedException ex) {}
if(throwsError){
throw new Error(Thread.currentThread().getName());
}else{
System.out.println(Thread.currentThread().getName());
}
}
}
public static void regularThreadPool(){
// Crashes individual thread; swallows error
ExecutorService threadPool = Executors.newFixedThreadPool(5);
threadPool.submit(new ErrorThrowingRunnable(false));
threadPool.submit(new ErrorThrowingRunnable(false));
threadPool.submit(new …Run Code Online (Sandbox Code Playgroud)