2

the following is a string that is displayed in a jquery confirm box.

warningString = "<p style='margin-top: 12px;'>Please Verify the following URL is a valid Redirect URL.</p> <a href= " + redirURL + "' target='_blank'>" + redirURL + "</a><p style='margin-top: 8px;'> By clicking verify you are confirming this is a valid URL and will proceed with checkout. </p>";

I would like the link to add http:// if the variable redirURL is missing it. I am a little lost on how i would do it.

thank you

user2101459
  • 579
  • 2
  • 8
  • 19

1 Answers1

7

So how about:

if(redirURL.IndexOf('http') !== 0)
  redirURL = 'http://' + redirURL;
warningString = "<p style='margin-top: 12px;'>Please Verify the following URL is a valid Redirect URL.</p> <a href= " + redirURL + "' target='_blank'>" + redirURL + "</a><p style='margin-top: 8px;'> By clicking verify you are confirming this is a valid URL and will proceed with checkout. </p>";
Gabe
  • 49,577
  • 28
  • 142
  • 181