在另一个网址中传递网址

passing url in another url

本文关键字:另一个      更新时间:2023-09-26

我有这个片段:

$('#button1').click(function(){
                window.location = "details.php?trans=Automatic&&mileage=19,695&&eng=6&&ext=White Platinum Metallic&&stock=45411&&vin=2FMGK5D89DBD08967&&location=Palm Beach, FL&&price=$28,999&&photo=http://content.homenetiol.com/1535/67692/165x10000/2013-Ford-Flex-Limited/d0dbf839ecc3492a850bfc73a6d9099d.jpg";
                });
我想在URL

中传递图像photo的URL,但它不起作用

  • 为什么?
  • 我该如何解决它?
您需要通过

encodeURIComponent 对 ? 之后的所有内容进行编码

$('#button1').click(function(){
            window.location = "details.php?"+ encodeURIComponent("trans=Automatic&&mileage=19,695&&eng=6&&ext=White Platinum Metallic&&stock=45411&&vin=2FMGK5D89DBD08967&&location=Palm Beach, FL&&price=$28,999&&photo=http://content.homenetiol.com/1535/67692/165x10000/2013-Ford-Flex-Limited/d0dbf839ecc3492a850bfc73a6d9099d.jpg");
  });