a874 a874 - 7 months ago 16
Javascript Question

How to redirect to a html page from a javascript snippet?

I am new to javascript. I want that when a user enters the username at the time of signup and that name already exists in the database,then i will show a prompt that

Name already exists
. and you need to enter another username.

Now i want to have a button in the same prompt box clicking on which, the user will be redirected to the Signup page

I am unable to figure out how to do this.
What i have done is this---

<!DOCTYPE html>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
prompt("Username already exists\n please enter another username");



you can put it in any js-script block you like. eg

  function redirectMe(url){
    window.location = url;

  setTimeout(redirectMe('http://stackoverflow.com'}, 3000);

will redirect to stackoverflow after 3000ms (=3s)