我想将2个网址合并为1个可点击的链接。第一个链接是设置cookie的链接,第二个链接是查询。将2个网址合并为1
第二:http://www.homeaway.com/search/keywords:boston
感谢
马克
我想将2个网址合并为1个可点击的链接。第一个链接是设置cookie的链接,第二个链接是查询。将2个网址合并为1
第二:http://www.homeaway.com/search/keywords:boston
感谢
马克
你不能 '结合' 的这两个网址,但你可以使他们两人的请求使用Javascript。
不幸的是,由于该URL位于另一个域中,因此您无法简单地发出AJAX请求。不过,您可以使用雅虎的YQL之类的网络服务为您做到这一点。
这个方法在这里解释:(看接受的答案)。 Cross-domain requests with JQuery using YQL
HTML:
<a href="http://www.homeaway.com/search/keywords:boston" class="my_link">Linky</a>
的Javascript:
// User clicks your link:
$('.my_link').click(function(){
// The link to fire silently before redirecting:
var first_url = "http://www.homeaway.com/?CID=a_cj_7123410&utm_source=cj&utm_medium=affiliates&utm_content=7123410&utm_campaign=10938928";
// YQL query:
var yql_url = "http://query.yahooapis.com/v1/public/yql?"+
"q=select%20*%20from%20html%20where%20url%3D%22"+
encodeURIComponent(first_url)+
"%22&format=xml'&callback=?";
// Fetch YQL URL before returning true:
return $.getJSON(yqlUrl2Use, function(data){
return true; // Goto the homeaway.com address.
});
});
真正的问题可能真的是'我可以做这个吗?'....! – watermanio
不知道你能做到这一点的标准链接。可以将第一页重定向到第二页。 – asantaballa