【问题标题】:How to open link in new window showing different url on addressbar如何在新窗口中打开链接,在地址栏上显示不同的网址
【发布时间】:2013-03-07 12:49:45
【问题描述】:
window.open(url,"_blank_");

我的网址中有一个敏感参数(密码),是否可以更改打开的窗口/标签中地址栏上显示的网址?

【问题讨论】:

  • 删除“_blank”部分。另外,查询字符串中不要有敏感参数(密码)。
  • 您将密码作为 GET 参数传递?
  • 即使您可以更改显示的 URL,我也可以轻松地在您的 JavaScript 中设置断点并查看 url 参数。

标签: javascript url


【解决方案1】:
<form method="POST" action="url" target="_blank">
    <input type="password" name="password" />
</form>

编辑:

同样,用 javascript 完成:

function navigate(url, data, method){
    var form = document.createElement('form');
    form.setAttribute('method', method);
    form.setAttribute('action', url);

    for(var name in data){
        var hidden = document.createElement('input');
        hidden.setAttribute('type', 'hidden');
        hidden.setAttribute('name', name);
        hidden.setAttribute('value', data[name]);
        form.appendChild(hidden);
    }
    document.body.appendChild(form); // Does not need this line in chrome
    form.submit();
}

用法:

navigate('url', { password: 'mypassword' }, 'POST');

【讨论】:

  • 另外,使用HTTPS发布敏感数据;使用纯 HTTP 可以轻松嗅探密码。
  • 我不确定我是否理解这种语法。我通过 URL 访问的服务不是由我实现的。这就是我想要达到的目标:confluence.atlassian.com/display/JIRA/Using+the+Issue+Navigator(访问受保护的数据)
  • 表格必须附加到 document.body:stackoverflow.com/questions/133925/… 一旦你更新你的答案,我接受它。
  • @user1977315 它无需向正文附加表单即可工作,我对其进行了测试(仅在 chrome 中)
  • @nagy.zsolt.hun 好的,正在更新
【解决方案2】:

使用这个语法

window.open(URL,name,specs,replace)

请参阅此文档以获取更多信息http://www.w3schools.com/jsref/met_win_open.asp

【讨论】:

  • 不推荐 w3schools.com。请参阅w3fools.com 为什么。此外,这不会更改显示的 URL。
猜你喜欢
  • 1970-01-01
  • 2013-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-30
  • 1970-01-01
  • 2019-05-06
  • 2013-10-07
相关资源
最近更新 更多