简体   繁体   中英

Is it possible to open a browser Window with desired content type using JS?

I had some data in an HTML table which wanted to be downloadable as a spreadsheet. Since both excel and open office can read CSV . I am generating a CSV using a PHP script on the server by passing it the data from HTML table using JS .

I was wondering If I could directly open a browser window with that CSV as its conetnt and if could set its content type to CSV , Will this work ? Is there a way to modify content type on the client ?

Server side, you need to have scripts that can generate two different "views" of the same data, the HTML table for viewing online, and the CSV for exporting. Once you have that, it's just a matter of using window.open in javascript to open a window on the CSV view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM