捕获控制台(console)关闭事件: 1.Ctrl+C信号: 2.Ctrl+Break信号: 3.用户系统关闭Console时: 4.用户退出系统时: 5.系统将要关闭时: using System; using System.Runtime.InteropServices; using System.Threading; using System.Diagnostics; namespace ConsoleApplication2 { public delegate bool Console
有兴趣的同学可以文章最后的代码复制贴到控制台玩玩. Go for Code 在正常模式下,一般只能向console 控制台输出简单的文字信息.但为了把信息输出得更优雅更便于阅读,除了cosole.log()方法外还可以调用 cosole.warn() 来输出警告信息,在控制台中出来的效果如下: 在输出信息前面会有一个带感叹号的黄色三角警告符号.似乎比一般的console信息要友好得多了.虽然图标是黄色的,但输出的文字仍然是黑色. 另外经常用到的是输出错误信息.可以通过调用console.erro
/** * 监听浏览器标签页的显示与隐藏 */ class ListenerPageVisibility { constructor () { // 设置隐藏属性和改变可见属性的事件的名称 this.hidden = '' this.visibilityChange = '' if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support this.hidden