以下代码可以产生正确的结果-指向正确目标的格式正确的可点击链接:
return "<a target=_blank href='https://www.betfair.com/exchange/#/football/event/" + fixture.eventId + "/market?marketId=" + fixture.marketId + "'>" + ('0' + now_utc.getDate()).slice(-2) + '-' + ('0' + monthData).slice(-2) + "<BR>" + ' ' + ('0' + hoursData).slice(-2) + ':' + ('0' + now_utc.getMinutes()).slice(-2) + "</a>";
以下是输出:
<a target="_blank" href="https://www.betfair.com/exchange/#/football/event/28934851/market?marketId=1.148981766">09-10<br> 18:45</a>
但是,当我将重定向添加到字符串时,它不会生成可点击的链接,如下所示:
return "<a target=_blank href='http://ads.betfair.com/redirect.aspx?pid=2614611&bid=9890&redirecturl=https://www.betfair.com/exchange/football/event/" + fixture.eventId + "/market?marketId=" + fixture.marketId + "'>" + ('0' + now_utc.getDate()).slice(-2) + '-' + ('0' + monthData).slice(-2) + "<BR>" + ' ' + ('0' + hoursData).slice(-2) + ':' + ('0' + now_utc.getMinutes()).slice(-2) + "</a>";
以下是输出:
<a target="_blank" href="http://ads.betfair.com/redirect.aspx?pid=2614611&bid=9890&redirecturl=https://www.betfair.com/exchange/football/event/28934851/market?marketId=1.148981766">09-10<br> 18:45</a>
我是否需要转义某些字符,还是重定向破坏了生成的URL?
谢谢
答案 0 :(得分:0)
我粘贴了您的网址:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<a target="_blank" href="http://ads.betfair.com/redirect.aspx?pid=2614611&bid=9890&redirecturl=https://www.betfair.com/exchange/football/event/28934851/market?marketId=1.148981766">09-10<br> 18:45</a>
</body>
</html>
它呈现得很好:
链接正常运行(至少重定向到betfair)。也就是说,您生成的URL看起来有点奇怪,这是您要呈现的目标:
<a target="_blank" href="http://ads.betfair.com/redirect.aspx?pid=2614611&bid=9890&redirecturl=https://www.betfair.com/exchange/football/event/28934851/market?marketId=1.148981766">09-10<br> 18:45</a>