When you click the button go to register

Asked

Viewed 95 times

-4

Hello, I’m a beginner and I would like to know how to redirect the user to a registration page when he presses the button to register or log in to the site.

<body>
<header class="menu-principal">
    <main>

    </main>

</header>
<main class="coluna menu-urls">
<div class="parte-1">
    <div class="menu">
        <ul>
            <li><a href="">HOME</a></li>
            <li><a href="">PRATIQUE</a></li>
            <li><a href="">SOBRE NÓS</a></li>
            <li><a href="">CONTATO</a></li>
            <li><a href="">AJUDA</a></li>
        </ul>
    </div>
</div>

<div class="inscrever">
    
    <input class="bnt st-button" type="button" value ="Inscrever-se"/>
    <input class="bnt es-button" type="button" value ="Entrar">
</div>
</main>
  • window.location.href = 'link-da-pagina-de-cadastro'

  • <input class="bnt st-button" type="button" value ="Subscribe" onclick="window.Location='https://answall.com/questions';" />

  • What should I do if someone answers my question? https://answall.com/help/someone-answers See how to mark response as you accept https://i.stack.Imgur.com/evLUR.png

  • Start here to get a quick look at https://answall.com/tour

2 answers

0

Some forms

1 - Redirecting with window.Location

Obs: location is synonymous with location.href

<input class="bnt st-button" type="button" value ="Inscrever-se" onclick="window.location='/questions';" /> 

.bnt {
  background-color: white;
  width: 200px;
  border: 3px solid #c9c9c9;
  font-size: 24pt;
  margin: 5px;
  color: #969696;
}

.bnt:hover {
  color: white;
  background-color: #969696;
  transition: color 0.2s 0.05s ease;
  transition: background-color 0.2s 0.05s ease;
  cursor: pointer;
}
<input class="bnt st-button" type="button" value ="Inscrever-se" onclick="window.location='/questions';" /> 

<input class="bnt st-button" type="button" value ="Entrar" onclick="window.location='/';" /> 

2 - javascript function

function novaPagina(num) {
var url=new Array();
url[0]="/questions";
url[1]="/";
window.location=url[num];
}
<input class="bnt st-button" type="button" value ="Inscrever-se" onclick="novaPagina(0)"> 
    
<input class="bnt es-button" type="button" value ="Entrar" onclick="novaPagina(1)">
    
    

  • How do I stop when press the sign up button and login go to a local page of my computer where I did the sign up screen? for example, I can put onclick="window.location.href = '#'"

  • @olamundo97, this # will not redirect to anywhere. The navigation on the switch is exactly as if it were on the server. You go to the folder where the file is, double click on it and it should open with the file address://C:/Users/Fulano/Documents/test/pagina_com_botao.html and clicking on the button opens the login page or sign up. If the two files are in the same folder then the button is enough, for example, onclick="window.Location='login.html';"

  • Wow, I got it!!! muitoo obg :)

-1

Opa!

You can do this in two ways: Using the (link) html tag:

Example:

<a href="www.seulink.com.br/inscrever-se">
  <input class="bnt st-button" type="button" value ="Inscrever-se"/>
</a>

If it’s just redirecting to another page that’s the simplest way.

But you can also do it with other programming languages like Javascript or PHP.

Would that be?

  • 2

    Friend your HTML is not valid! Not allowed to use an Input within an A https://prnt.sc/tot7os. if you want to test on your own you just put your HTML here https://validator.w3.org/nu/#textarea Use a button or style with CSS for the Link to look like the button style

  • It may not be allowed but I ask, does it work? in all browsers and versions? ha good, right, dad doesn’t let

  • Boy... I flew in that answer... using window.Location is the best solution.

  • @Leocaracciolo sweep dirt under the carpet resolves? Drinking toilet water quenches thirst? I do not know if you work validating is code, or with some automatic validator in the compilation etc, but in this particular case there are several workarounds fully valid... but each maintain the level of quality that manages.

  • @hugocsl, It depends on the context, if you’re in a war I bet you’ll drink toilet water in the absence of another source. This talk of not valid for me is blablah. WORKS, yes, EN greetings!

  • @Leocaracciolo in war this is the type of soldier who dies in the first combat or who shoots himself in the foot. Abs

  • @hugocsl, cheap philosophy, that’s what you say. Go see if I’m around the corner.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.