Embed link to search box redirection

2

I have the http://www.algumacoisa.com/d/ I need a code where there is a text box, the user types the link and clicks "go" then it is directed to

http://www.algumacoisa.com/d/HTTP://WWW.LINKDOUSUÁRIO.COM

However, no database. Is it possible?

I could not get more specific because I did not find anything like it or words to describe what I wanted.

    
asked by anonymous 10.09.2016 / 03:56

2 answers

2

So I understand you just need to concatenate the linked link + your url, I think javascript itself does this:

HTML:

<input type="text" id="link" />
<button id="ir" onclick="ir()">IR</button>

JS

function ir() {
 var link = document.getElementById('link').value;
 var url = "http://www.algumacoisa.com/d/";
 var linktodo = url+link;
 window.open(linktodo, '_blank');
}

It can be simpler using jQuery if you use it, if you do not want to open it on another tab, take the blank. I hope I have helped.

    
10.09.2016 / 17:25
2

Even though I already have a correct answer, I'll post a suggestion with jQuery, as well remembered the friend who answered:

HTML:

<input type="text" id="link" />
<button id="ir">IR</button>

jQuery:

$(function(){
    $('#ir').click(function(){
        window.location.href = "http://www.algumacoisa.com/d/" + $('#link').val();
    });
});
    
29.09.2016 / 18:52