最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - Modify HTTP response header with (Client-side) Javascript - Stack Overflow

programmeradmin1浏览0评论

I'm working on a website, and I've run into trouble modifying an HTTP Response header using (client-side) JavaScript. I have exactly zero idea how to do this. I know (roughly) how to make the 'for' loop to modify the header, but I don't know how to access the header within the script. Could y'all fine people help me with this fun task?

I'm working on a website, and I've run into trouble modifying an HTTP Response header using (client-side) JavaScript. I have exactly zero idea how to do this. I know (roughly) how to make the 'for' loop to modify the header, but I don't know how to access the header within the script. Could y'all fine people help me with this fun task?

Share Improve this question edited Jan 15, 2014 at 22:16 Zach Lysobey 15.8k21 gold badges100 silver badges152 bronze badges asked Jan 15, 2014 at 22:05 bluebunnybluebunny 3153 silver badges14 bronze badges 11
  • 3 mind if I ask what you're trying to acplish by doing this? – Zach Lysobey Commented Jan 15, 2014 at 22:07
  • 1 But I think this has your answer: stackoverflow./questions/220231/… – Zach Lysobey Commented Jan 15, 2014 at 22:08
  • 2 @Barmar: Depends on where the JavaScript is running. If it's running on the server... – T.J. Crowder Commented Jan 15, 2014 at 22:08
  • 1 @T.J.Crowder Unless they specifically say they're using something like Node.js, I'm going to regularly assume that JS == client, not server. – Barmar Commented Jan 15, 2014 at 22:09
  • 1 Alright, for clarification: I need to modify the response header to remove X-Frame-Options to load one site in an iFrame. Is it possible to have the script run after receipt of the header, then pass the header along to the iFrame afterwards? – bluebunny Commented Jan 15, 2014 at 22:10
 |  Show 6 more ments

1 Answer 1

Reset to default 8

With client-side JavaScript (JavaScript running in a browser), you can't do this; by the time the JavaScript code runs, the headers have already been processed.

发布评论

评论列表(0)

  1. 暂无评论