2

以下是在 jquery 确认框中显示的字符串。

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>";

如果变量 redirURL 丢失,我希望添加 http:// 的链接。我对如何做到这一点有点迷茫。

谢谢你

4

1 回答 1

7

那么怎么样:

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>";
于 2013-06-07T16:53:00.973 回答