简体   繁体   中英

How to pass html code in url query string

I need to pass a html message through url query string. But i am getting error. I have tried encodeURIComponent() , encodeURI(), escape()

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

Any help will be really appreciated.

You don't need to encode html somehow, the simple window.open should work. Without knowing what error do you receive it is pretty hard to tell what do you issue.

Also please take a note that the maximum request length for GET requests are pretty short, as you can see in this post , so sending raw html in a query string does not look like a clean solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM