有人制作了一个网页,从Eventbrite中摘取事件数据,将其写入SVG,使用Amazon Web服务,并将其保存为PDF来创建Fliers。
它在这里工作:www.ilovemylaser.com/fliers.html。
但是,如果我在地址行中使用'#',它会破裂,因此,对于圣地亚哥的#
如果您查看www.admaticonsulting.com/resources/fliers2.html,我使用了'#2'。如果您单击传单,您会发现城市,地点名称,时间,州和邮政编码丢失了。将其与第一个链接中的千橡树般的传单进行比较。
此行在代码中,我很确定这是问题:
var output = "<p><a href="h t t p ://ec2-52-42-194-56.us-west-2.compute.amazonaws. com/task.php?date=" + date + "&staddress=" + venue + "&venue=" + ven3 + "&city=" + city + "®ion=" + region + "&postal_code=" + postal_code +"&time="+ time + "">" + date + " - " + city + "</a><br></p>";
现在我不能发布2个以上的链接,但是如果您单击任何传单链接,您会看到它会显示一个链接,然后解决另一个链接。
可以肯定的是#会影响这一点。同样,具有'#'的链接的"解决链接"中还有一些空间。没有任何空间
如何使用#且没有传单上的数据?
您需要使用encodeURIComponent
来编码每个查询字符串值:
var output = "<p><a href="h t t p ://ec2-52-42-194-56.us-west-2.compute.amazonaws. com/task.php?date=" + encodeURIComponent(date) + "&staddress=" + encodeURIComponent(venue) + "&venue=" + encodeURIComponent(ven3) + "&city=" + encodeURIComponent(city) + "®ion=" + encodeURIComponent(region) + "&postal_code=" + encodeURIComponent(postal_code) +"&time="+ encodeURIComponent(time) + "">" + date + " - " + city + "</a><br></p>";
a#在URL中启动片段标识符,该标识符由浏览器或其他客户端本地处理;它是发送到服务器的HTTP请求中未包含的,因此无法在服务器上的任何处理中使用。要在URL中包含"保留"字符作为数据,您必须对其进行编码。请注意,链接是https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters
,当您单击它时,从服务器获得的页面是https://en.wikipedia.org/wiki/Percent-encoding
,则您的浏览器位置到Percent-encoding_reserved_characters
的锚定标签。