F12的快捷键的js函数_javascript技巧_脚本之家,强制关闭窗口
分类:高并发

<input type="button" value="强逼关闭窗口" onclick="window.openner=null;window.close(卡塔尔国;">

//找window的二种办法

复制代码 代码如下: function window.onhelp(卡塔尔国{return false} //屏蔽F1援助/*keyCod从113-122个别禁止使用了F2-F12键,13禁止使用了回车键,8禁止使用了退格键*/ document.onkeydown = function(){ if(window.event && window.event.keyCode == 113) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 114) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 115) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 116) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 117) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 118) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 119) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 120) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 121) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 122) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 123) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 13) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 8) { alert(str+"n请使用Del键进行字符的去除操作!"卡塔尔(قطر‎; window.event.returnValue=false; } if(window.event && window.event.keyCode == 505卡塔尔国{ alert window.event.returnValue=false; } }

[Ctrl+A 全体增选 提醒:你可先改善部分代码,再按运营]

UIWindow *window1 = [UIApplication sharedApplication].keyWindow;

UIWindow *window2 = [UIApplication sharedApplication]windows[0];

UIWindow *window3 = [UIApplication sharedApplication].delegate.window;


- (void)viewDidLoad {

//self本类(NowViewController)的对象

//super父类(UIViewController)的对象

//先加载父类视图,确定保证子类视图顺遂加载

[super viewDidLoad];

//视图调节器在创立刻会自动生成叁个view,作为视图调整器的多少个自带属性

//设置背景颜色

self.view.backgroundColor= [UIColor blueColor];

//在viewDidLoad方法中写代码

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 150, 100)];

label.text = @"viewController";

[self.view addSubview:label];

[self findWindow];

}

//系统的触动方法,当手指触摸到显示屏时调用

- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {

//1.导入头文件

//2.开立视图调控器对象

NowViewController *vc = [[NowViewController alloc] init];

//3.找window,无法重复成立window,因为一个一定要有二个window

UIWindow *window = self.view.window;

//4.设置为window的根视图调整器

window.rootViewController= vc;

//上一句代码把window的根视图调控器换掉了,所现在后self.view已经不在window上了,所以用self.view.window找不到window

//[self findWindow];

}

//找window

- (void)findWindow {

//方法一(不确定):

UIWindow *window1 =self.view.window;

//方法二(常用):

UIWindow *window2 = [UIApplication sharedApplication].keyWindow;

// UIWindow  *window2 = [[UIApplication sharedApplication] keyWindow];

//方法三:

UIWindow *window3 = [UIApplication sharedApplication].windows[0];

//方法四(最安全):

//找到应用程序

UIApplication *app = [UIApplication sharedApplication];

//UIWindow *window4 = [UIApplication sharedApplication];

//找到应用程序的入口类

AppDelegate *delegate = app.delegate;

//找到入口类中的属性window

UIWindow *window4 = delegate.window;

NSLog(@"window1 = %@",window1);

NSLog(@"window2 = %@",window2);

NSLog(@"window3 = %@",window3);

NSLog(@"window4 = %@",window4);

}

本文由10bet手机官网发布于高并发,转载请注明出处:F12的快捷键的js函数_javascript技巧_脚本之家,强制关闭窗口

上一篇:中国重庆火锅美食节,火锅美食文化节火辣来袭 下一篇:Javascript之获取屏幕宽高,显示屏幕分辨率
猜你喜欢
热门排行
精彩图文