问题描述
有人制作了一个网页,该网页从eventbrite中提取事件数据,将其写入SVG,使用Amazon Web服务,并将其另存为PDF来创建传单.
Someone made a web page that pulls event data from eventbrite, writes it on an SVG, uses Amazon Web services, and saves it as a PDF to create fliers.
它在这里有效:www.ilovemylaser.com/fliers.html.
It works here: www.ilovemylaser.com/fliers.html.
但是,如果我在地址行中使用#",则它会中断,因此,对于圣地亚哥市以后的地址,我将#"替换为"No".
However, if I use '#' in the address line, it breaks, so for the San Diego ones onward, I've replaced '#' with 'No.'.
如果您访问www.admaticonsulting.com/resources/fliers2.html,我使用的是#2".如果单击传单,您会看到城市,地点名称,时间,州和邮编丢失.将其与第一个链接中的千橡"飞行器进行比较.
If you look at www.admaticonsulting.com/resources/fliers2.html, I've used '#2'. If you click the flier, you'll see that the city, venue name, time, state and zip are missing. Compare that to the Thousand Oaks flier from the first link.
此行在代码中,我很确定这是问题所在:
This line is in the code, and I'm pretty sure it's the issue:
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>";
现在我不能发布两个以上的链接,但是如果您单击任何传单链接,您会看到它会显示一个链接,然后解析为另一个链接.
Now I can't post more than 2 links, but if you click any flier link, you'll see it will display one link, then resolve to something another.
很确定#会影响到这一点.另外,在已解析的链接"中,带有#"的空格.没有的空间中没有任何空间
Pretty sure the # is affecting this. Also, there are spaces in the "resolved link" of the ones that have '#'. There aren't any spaces in the ones that don't
如何使用#并且传单上没有缺少数据?
How can I use # and not have missing data on the flier?
推荐答案
您需要使用encodeURIComponent
对每个查询字符串值进行编码:
You need to use encodeURIComponent
to encode each the the query string values:
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>";
这篇关于数字符号/哈希符号(#)中断代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!