【问题标题】:How to pass html code in url query string如何在 url 查询字符串中传递 html 代码
【发布时间】:2019-10-18 23:13:30
【问题描述】:

我需要通过 url 查询字符串传递一个 html 消息。但我收到错误。我试过 encodeURIComponent() 、 encodeURI() 、 escape()

    var uriMessage = encodeURIComponent("<p>This is my test message..</p>");
    window.open("/controller/action?param=" + uriMessage, "_blank");

任何帮助将不胜感激。

【问题讨论】:

  • 如果 uriMessage 变量请显示示例
  • @wasanga7,问题已更新
  • 也许这会help
  • 请发布错误。
  • 遇到什么错误?

标签: jquery html vue.js query-string urlencode


【解决方案1】:

您不需要以某种方式对 html 进行编码,简单的 window.open 应该可以工作。在不知道您收到什么错误的情况下,很难说出您发出了什么问题。

另请注意,GET 请求的最大请求长度非常短,正如您在 post 中所见,因此在查询字符串中发送原始 html 看起来不是一个干净的解决方案。

【讨论】:

    猜你喜欢
    • 2011-03-13
    • 2020-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多