+ 4

How can I close the window if input is wrong

I am practicing to make a password protection website and I want to make a program in which if the user writes wrong password then the website closes Please tell the answer in JS

1st Aug 2020, 6:10 AM
Raghu Rao
Raghu Rao - avatar
12 Answers
+ 3
Use validation and window object if you open window using undergiven method. Onclick button let a fxn happen as Function name(){ var w = window.open(url,_blank); } Then If( incorrect password){ w.close() } I hope this will work
1st Aug 2020, 6:23 AM
Divya Mohan
Divya Mohan - avatar
+ 3
Scripts closing current window/tab had been frowned upon from its notoriety "bad reputation". Browser vendors are not happy with such scripts, causes users' inconvenience at least. Anyways, you go read this 👇 https://www.thesitewizard.com/javascripts/close-browser-tab-or-window.shtml
1st Aug 2020, 6:27 AM
Ipang
+ 3
Thanks if you are free can you send me a code pls
1st Aug 2020, 6:39 AM
Raghu Rao
Raghu Rao - avatar
+ 2
Then tell me a way in which I can redirect the person to another window if he fills wrong password
1st Aug 2020, 6:31 AM
Raghu Rao
Raghu Rao - avatar
+ 2
In validation fxn state to return false if password wrong In this way he will be stand at login page untill doesn't type correct password
1st Aug 2020, 6:37 AM
Divya Mohan
Divya Mohan - avatar
+ 2
I will type a code and send here tomorrow Please tell me my mistakes if I write the code wrong
1st Aug 2020, 6:41 AM
Raghu Rao
Raghu Rao - avatar
+ 2
Here you can set you requirement in if condition . If password =12345 user can do what you allow else nothing else trying password https://code.sololearn.com/W16L10S6o03P/?ref=app
1st Aug 2020, 6:55 AM
Divya Mohan
Divya Mohan - avatar
+ 2
Thanks alot
1st Aug 2020, 7:04 AM
Raghu Rao
Raghu Rao - avatar
+ 2
Don't forget to link your project here😆😆
1st Aug 2020, 7:07 AM
Divya Mohan
Divya Mohan - avatar
+ 1
what does it mean by fxn and which URL should I write
1st Aug 2020, 6:25 AM
Raghu Rao
Raghu Rao - avatar
+ 1
Yeah
1st Aug 2020, 8:15 AM
Raghu Rao
Raghu Rao - avatar
+ 1
How I store data in inner HTML
3rd Aug 2020, 4:59 AM
Pravin Thiran
Pravin Thiran - avatar