& 符号不通过 url

发布于 2024-08-11 05:48:34 字数 239 浏览 6 评论 0原文

在我的网站 www.gibberize.com 上,如果您在顶部文本区域中输入单词“and”,则该字符“&”将出现在第二个文本区域中。

问题是“tweet it”链接会将第二个文本区域的文本附加到 URL 并继续访问该链接,但因为它是一个 & 符号,所以会破坏文本。

有什么解决办法吗?

On my site www.gibberize.com if you type in the word "and" in the top textarea, the character "&" will appear in the second textarea.

The problem is that the "tweet it" link will then append the second textarea's text to a url and proceed to the link, but because it is an ampersand it will break the text.

Any solutions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

分分钟 2024-08-18 05:48:34

Use the encodeURIComponent function. You could just change it to %26 yourself, but it's safer to use the function provided, as that will take care of any other odd characters that might get messed up in transmission.

只等公子 2024-08-18 05:48:34

是的,在附加推文之前转义 & 符号,更改任何 & 符号。 %26。你可能想要

encodeURIComponent()

对整个文本

。注意:我建议的原始函数是 escape()。

Yes, escape the ampersand symbol before appending the tweet, change any & for %26. You may want to

encodeURIComponent()

the whole text.

Note: original function I suggested was escape().

烧了回忆取暖 2024-08-18 05:48:34

使用 PHP 的 urlencode() 函数。

Use PHP's urlencode() function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文