简体   繁体   English

使用 Javascript 在 URL 中使用 at (@) 符号

[英]Using at (@) symbol in URL with Javascript

The Scenario情景

I'm using MailChimp to send someone to a landing page, and appending their email address to the URL like so http://example.com?email=someone@test.com我正在使用 MailChimp 将某人发送到登录页面,并将他们的电子邮件地址附加到 URL 中,例如http://example.com?email=someone@test.com

I then intend to use Javascript to grab the email address from the URL.然后我打算使用 Javascript 从 URL 中获取电子邮件地址。

The Problem问题

According to URL best practices, you're apparently not supposed to use the @ symbol in URLs unless it's for its intended purpose (username@password).根据 URL 最佳实践,您显然不应该在 URL 中使用 @ 符号,除非它是出于其预期目的(用户名@密码)。

Seeing as I am using MailChimp to insert the email address, I cannot encode the @ character using % symbol .当我使用 MailChimp 插入电子邮件地址时,我无法使用 % 符号对 @ 字符进行编码

Is there likely to be a scenario in any browser that will reject the use of this @ symbol or mess things up in some way?在任何浏览器中是否可能会出现拒绝使用 @ 符号或以某种方式搞砸的情况? Or is it just "not best practice"?或者这只是“不是最佳实践”? I've tested it in a few browsers and seems to be fine, but just want to be sure.我已经在几个浏览器中对其进行了测试,似乎没问题,但只是想确定一下。

You answered your own question.你是在自问自答。 Test in the browsers you care about.在您关心的浏览器中进行测试。 Some will in fact get messed up, but they are nowadays irrelevant, unless you for some reason want to support them.有些人实际上会搞砸,但现在它们无关紧要,除非您出于某种原因想要支持它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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