6

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.

Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
Matt
  • 63
  • 1
  • 3

1 Answers1

10

Just concatenate the strings together:

javascript:
(function() { 
    var val= prompt("Enter #",""); 
    if (val) 
        location="http://www.test.com/"+escape(val)+"/html/stuff";
})()
Brett Green
  • 3,535
  • 1
  • 22
  • 29