开发者

Changing Response.Header makes javascript unresponsive on my page

开发者 https://www.devze.com 2022-12-09 03:55 出处:网络
I use response.AddHeader(\"content-disposition\", \"attachment;filename=file.xls\"); response.ContentType = \"application/vnd.ms-excel\";

I use

response.AddHeader("content-disposition", "attachment;filename=file.xls");
response.ContentType = "application/vnd.ms-excel";

as a method to generate a CSV/Excel file in my page. It works like a charm, however, after I open the file, the scripts on my page are unresponsive; trying tie J开发者_如何学运维S onclick on any component on my page dosen't work.

Any Ideas/suggestions???


The root cause is the Content Type.

Javascript only works with certain combinations of ContentType ... of which 'js' itself must be a part. Try reverting ContentType dynamically to JS compatible type.

0

精彩评论

暂无评论...
验证码 换一张
取 消