如何避免在 javascript window.open 上剥离一层转义编码?
我们的网站第一次有一个包含多层编码的链接,需要存在该链接才能通过公司的身份验证门户。当用户从 window.open 函数复制目标并将其粘贴到文本编辑器中时,新窗口中显示的目标也是如此 - 当您比较两者时,窗口中显示的目标已被删除一层编码。
我们已经确定这种情况发生在客户端上,但没有人知道原因或如何解决它。这是一个常见问题吗?我们错过了什么?
示例:我们有一个 javascript 函数:
function OpenStandardWindow(url, h, w)
{
var t = (screen.height / 2) - (h / 2) - 75;
var l = (screen.width / 2) - (w / 2);
window.open(url,"_blank","height=" + h + ",width=" + w + ",top=" + t + ",left=" + l + ",resizable=yes,scrollbars=yes,status=yes,toolbar=yes,location=yes,menubar=yes");
}
它可以很好地处理没有转义编码的 URL。
但是当像这样的 URL http://www.site.com/dispatcher?realm=example&BaseURL=%25253dhttps%2525253a%2525252f%2525252fexample.domain.com..etc。
注意,新的 URL 丢失了一层转义编码(即“25”)。
为什么会发生这种情况?
For the first time in our site we have a link that has several layers of encoding that needs to be there in order to get through the company's authentication portal. When the user copies the target from the window.open function and pastes it in text editor, ditto on the target that shows up in the new window--when you compare the two, the one that shows up in the window has been stripped of one layer of encoding.
We've determined that this is happening on the client-sdie, but no one knows why or what to do to work around it. Is this a common problem? What are we missng?
Example: we have a javascript function:
function OpenStandardWindow(url, h, w)
{
var t = (screen.height / 2) - (h / 2) - 75;
var l = (screen.width / 2) - (w / 2);
window.open(url,"_blank","height=" + h + ",width=" + w + ",top=" + t + ",left=" + l + ",resizable=yes,scrollbars=yes,status=yes,toolbar=yes,location=yes,menubar=yes");
}
which works great with URLs without escaped encoding.
but when a URL like this http://www.site.com/dispatcher?realm=example&BaseURL=%25253dhttps%2525253a%2525252f%2525252fexample.domain.com..etc.
what appears in the window is:
http://www.site.com/dispatcher?realm=example&BaseURL=%253dhttps%25253a%25252f%25252fexample.domain.com
Notice that the new URL has lost a layer of escape encoding (i.e. '25').
Why is this happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论