#在URL中跳过之后的所有参数


# in URL skipping all parameter after that

当使用get方法提交表单时,如果我们在任何字段中传递# character,它会跳过该字段之后的所有参数。

bookmy_car.php ? pod = 6, room_id = 32, starthour = 14, startminute = 00, startday = 07, startmonth = 08年,startyear = 2015, endhour = 16, endminute = 00, endday = 07, endmonth = 08年,endyear = 2015, end_date = 1438927200, email_conf = 1, cost_code =, desc =旅行description& trip_comment = # , day_rate = 68.00, hourly_rate = 6.60, hourly_km_rate = 0.35, dur_hours = 2hours& location_charge = 0.00, damage_cover_charge = 5.00, total_free_kms =,长期= 0,rt =, minbooking = 3600, returl =, returl_newid =, rep_id =, edit_type =, insPlanid = 3, plan_name = goOccasional& id = 3, driver_username_id = 2,

我们如何保护它?我尝试了escape()encodeURI()的JavaScript函数,它没有帮助。

我同意@dgsq。但我更喜欢只使用encodeURI,这样他就可以得到uri,因为它在下一页。

alert( encodeURI('&trip_comment=#&day_rate=68.00') )

这是因为查询字符串#中的哈希邦被解释为location.hash并作为GET参数进行热处理。在使用URI之前,需要对它进行适当的编码。例如encodeURIComponent:

alert( encodeURIComponent('trip_comment=#') )