Reputation: 45
This is the sample code:
var users = ["ownersName","Others"];
var name=prompt("Enter your name");
if(name==users[0]){
w
alert("Hey"+' '+name)
alert("You have been granted the webMaster Role!")
}
else{
console.log("hello user");
}
I want to allow the user to view the page only if his name satisfies 'ownersName'.
Upvotes: 2
Views: 39
Reputation: 4915
You can redirect to blank URL about:blank
or
document.documentElement.innerHTML='';
to restrict the user to view page
var users = ["ownersName","Others"];
var name=prompt("Enter your name");
if(name==users[0]){
w
alert("Hey"+' '+name)
alert("You have been granted the webMaster Role!")
}
else{
document.documentElement.innerHTML = '';
//window.location = 'about:blank';
}
Upvotes: 2