+ 18

How to restrict entry in a website ??

Suppose, I have developed a website which is not suitable for children below 12 years. How can I display a pop-up asking them to confirm that they are not below 12 years ? The pop-up should have 2 options: One of confirm and other to go back. Edit : If the user clicks back, he should be redirected to the page from where he came to the website.

11th Mar 2018, 6:37 AM
Arushi Singhania
Arushi Singhania - avatar
19 odpowiedzi
+ 13
var user=confirm ("Are you above 12"); if (user == true){ alert("Welcome to our site!") }else{ window.location.href ="https://www.sololearn.com"; } here it is
11th Mar 2018, 7:02 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 9
@shudarshan thanks for the help, bro !!
11th Mar 2018, 7:04 AM
Arushi Singhania
Arushi Singhania - avatar
+ 8
var user=confirm ("Are you above 12"); if (user == true){ alert("Welcome to our site!") }else{ alert("You are below 12,Please Read our Terms and policy") } but its not enough you can make a another page load when you get false reply ,page can be of term and policy
11th Mar 2018, 6:50 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 7
you can use confirm() but to continue to the page i dont know
11th Mar 2018, 6:43 AM
Blizz
Blizz - avatar
+ 7
@blizz i had tried confirm but if user choose cancel then also the html part executes.
11th Mar 2018, 6:44 AM
Arushi Singhania
Arushi Singhania - avatar
+ 7
@Sudarshan How can I load T&C page??
11th Mar 2018, 6:52 AM
Arushi Singhania
Arushi Singhania - avatar
+ 7
ok
11th Mar 2018, 6:55 AM
Arushi Singhania
Arushi Singhania - avatar
+ 7
@jan I just want to display a pop-up box. You will find many such age restricted website. They do not need ID proofs.
11th Mar 2018, 7:03 AM
Arushi Singhania
Arushi Singhania - avatar
+ 6
@Sudarshan For ex, someone has opened this website through a link on www.sololearn.com. Is it possible to acheive that when we click cancel we will got redirected to the page www.sololearn.com
11th Mar 2018, 2:42 PM
Arushi Singhania
Arushi Singhania - avatar
+ 6
@Vikash I don't want to send user to T&C page. Let, he came to my website from a link on www.sololearn.com. So, I want to redirect him to www.sololearn.com if he clicks back or cancel.
12th Mar 2018, 9:03 AM
Arushi Singhania
Arushi Singhania - avatar
+ 6
@Vikash Actually I have no idea from where the users came to my page. I have taken www.sololearn.com just as an example. There can be any url instead of it.
12th Mar 2018, 11:23 AM
Arushi Singhania
Arushi Singhania - avatar
+ 6
@Vikash Thanks for the help. It is exactly what I was searching for.
12th Mar 2018, 11:26 AM
Arushi Singhania
Arushi Singhania - avatar
+ 6
@Vikash Ok, I will google it.
12th Mar 2018, 11:35 AM
Arushi Singhania
Arushi Singhania - avatar
+ 5
wait i will post all code , wait bro
11th Mar 2018, 6:55 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 5
@jan agreed it is good to use Gmail age verification.
11th Mar 2018, 7:05 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 4
var confirm = confirm("Are you above 12?"); if(confirm){ window.location.href = "url of your website"; } else { window.location.href= "url of your terms and conditions page"; }
12th Mar 2018, 8:16 AM
Vikash Pal
Vikash Pal - avatar
+ 4
@Arushi Replace "url of your terms and condition page" with "www.sololearn.com".
12th Mar 2018, 9:06 AM
Vikash Pal
Vikash Pal - avatar
+ 3
You can use window.history.go(-1)
12th Mar 2018, 11:25 AM
Vikash Pal
Vikash Pal - avatar
+ 3
This is HTML5 History API. You can search on google for more info.
12th Mar 2018, 11:34 AM
Vikash Pal
Vikash Pal - avatar