← Desenvolvimento

Formulário: Inserir e abrir URL dinâmico

Lida 2261 vezes

Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Boa tarde.

Eu já tive um código em JS e outro em PHP onde eu tinha um input, colocava um texto e esse texto iria abrir uma página:
http://site.com/textoinserido

Alguém me arranja algo do género?

Obrigado.
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Keep searching :P
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Offline

André Freitas 
Membro
Mensagens 941 Gostos 16
Troféus totais: 29
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Tenta isto:

<form name="openlocation">
Insira a Palavra<input type="text" name="href">
<input type="button" value="Go To" onClick="location.href='http:/oteusite.com/'+document.openlocation.href.value;; ">
</form>

Fonte: http://www.java-scripts.net/javascripts/URL-Input-Box.phtml
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Código: [Seleccione]
<form name="openlocation">
<input type="text" name="href">
<input type="button" value="Go To" onClick="location.href='http://meusite.com/'+document.openlocation.href.value;; ">
</form>

Estou neste momento a usar este código que faz com que escreva algum no input e ele abra www.meusite.com/oqueescrevi

Mas tem um problema. Se eu clicar no botão, tudo bem. Se clicar no ENTER do teclado, temos o caldo entornado.

Alguém tem alguma solução
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Em relação ao enter, resolvido.

Agora é o botão que não funciona. :lol:

Eu substitui todos os " deste pequeno código por ' porque é para ser inserido num echo.

Acho que é por isso.... Alguma solução?


EDIT: Resolvido. Substitui todos os ' por \"

Abraço