/    Sign up×
Community /Pin to ProfileBookmark

changing headers in a new window

I have a webpage which the user can manipulate (sorting/filtering) and I want the user to have the option to download the tables.

This is in a jsp file. Currently I can resubmit the page and pass in a value so I know to save it as xls and based on that value I can set the content type to that of a excel file.
response.setContentType(“application/vnd.ms-excel”);

I would like to save the page without resubmitting the page.

What I thought might work was creating a new window and setting the http header’s context type on the window I just opened to that of a excel file. But it seems to have no effect on the page and just loads in the window.

This is my function I am calling.. Am I doing something wrong? Or is my logic just flawed and this wont work.

function save()
{
var generator=window.open(”,’name’,’height=400,width=500′);
generator.document.write(‘<html><head><title>Popup</title>’);
generator.document.write(‘<meta http-equiv=”Content-Type” content=”application/vnd.ms-excel”>’);
generator.document.write(‘<meta http-equiv=”Content-Disposition” content=”attachment; filename=Export.xls;”>’);
generator.document.write(‘<link rel=”stylesheet” href=”style.css”>’);
generator.document.write(‘</head><body>’);
generator.document.write(‘<p>This page was generated by the main window.</p>’);
generator.document.write(‘</body></html>’);
generator.document.close();
}

Thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@kyle999312authorMar 30.2006 — anyone?
×

Success!

Help @kyle999312 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...