使用&;正在干扰操作


Querystring value with a & is disturbing the operations

Iam正在调用一个查询字符串值,该值有时带有'&'例如:

 price_add.php?supplier_name=Devices & Services Co.&tender_id=481

在上面的例子中,supplier_name=Devices&服务(在supplier_name中有一个&),操作只是使用"Devices"而不是"Devices&服务"。我将如何在php中解决这个问题。我以以下格式调用此脚本:

 <A onclick="window.open('comparitive_files/price_add.php?supplier_name={$supplier_name}&amp;tender_id={$tender_id}','mywindow','width=1200,height=800, scrollbars=yes, resizable=yes')" href="#">PRICE</A>

在设置URL之前使用javascript encodeUri()函数。例如:

var url = encodeURI('price_add.php?supplier_name=Devices & Services Co.&tender_id=481');

console.info(url);

"price_add.php?supplier_name=Devices%20&%20Services%20Co.&tender_id=481"