whatsapp://send?从'&'文本剪切字符串性格到最后? [英] whatsapp://send?text cut string from '&' character till end?

查看:153
本文介绍了whatsapp://send?从'&'文本剪切字符串性格到最后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试添加一个可以在WhatsApp中共享的链接:

I'm trying to add a link that can be shared in WhatsApp:

例如:

"whatsapp://send?text=http://www.example.com/products/women/dresses?sessionid=34567&source=google.com"

但是WhatsApp中发送的链接已从'&'中截断.直到最后.(第二个参数)

But the link that is sent in WhatsApp is truncated from the '&' until the end. (the second parameter)

当我尝试时会发生相同的事情:

The same thing happens when I try:

"WhatsApp://send?text=http://www.example.com/prod&ucts/"

(请注意在"prod& ucts"一词中间的&")&"后的文字被截断.

(note the '&' in the middle of the word 'prod&ucts') The text after the '&' is truncated.

任何建议为什么会发生这种情况以及如何解决?

Any suggestions why this is happening and how can I fix it?

推荐答案

它将被切断,因为'&'表示新的查询字符串参数.您可以使用 encodeURI JavaScript函数对URL中的字符串参数进行编码来修复它.&字符将编码为%26".

It'll be cutting it off because an '&' denotes a new query string parameter. You can fix it by encoding the string parameter in your URL using the encodeURI JavaScript function. The & character will encode to "%26".

这篇关于whatsapp://send?从'&'文本剪切字符串性格到最后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆