【问题标题】:is that possible to send header information in $window.open(url) method是否可以在 $window.open(url) 方法中发送标头信息
【发布时间】:2016-05-21 20:04:00
【问题描述】:

我正在使用 API 从服务器下载文件,为此我必须在标头中发送会话详细信息,我如何使用 angularjs 来做到这一点?请帮帮我。

提前感谢您的建议。

【问题讨论】:

    标签: angularjs


    【解决方案1】:

    我不建议使用 window.open 传递参数。

    但是你可以像这样使用 window.open。

    var params = {
     access_token: 'An access_token',
     other_header: 'other_header'
    };
    
    //Add authentication headers in URL
    var url = [url_generating_pdf, $.param(params)].join('?');
    
    //Open window
    window.open(url);
    

    请查看详细信息here

    【讨论】:

    • 不,对我不起作用。这只是将我想要的标题中的值附加到 URL 字符串中。这不是一回事。
    • 不要在 URL 中放置令牌 - 这是不安全的 stackoverflow.com/a/46141515/4233629
    【解决方案2】:

    - 无法使用$window.open 直接发送标头

    - 这是可能的,但不是直接的方法,如果你有服务器端控制,那么你可以在查询字符串中设置header 值并从后面的查询字符串中解析它-结束。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-08
      • 1970-01-01
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多