Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bookmarklet - Add an input to middle of a URL?

This is probably extremely simple but I am a total newbie. I use something like this to add an input to the end of an URL

javascript:
(function() { 
    var val= prompt("Enter #",""); 
    if (val) 
        location="http://www.test.com?param="+escape(val);
})()

But now I want to add something to the middle of another url like:

http://www.test.com/ENTERSOMETHINGHERE/html/stuff/

I have no clue what I am doing.

like image 485
Matt Avatar asked May 21 '15 18:05

Matt


1 Answers

Just concatenate the strings together:

javascript:
(function() { 
    var val= prompt("Enter #",""); 
    if (val) 
        location="http://www.test.com/"+escape(val)+"/html/stuff";
})()
like image 93
Brett Green Avatar answered Sep 29 '22 23:09

Brett Green