javascript and Content-Type

W

workitharder

Is there any way whatsoever to manipulate the MIME content-type at the
server-side? My goal is to redisplay a (very large) html table with
the "Content-Type:application/vnd.ms-excel" http header. This is to
avoid the need to re-download the data which is already there.

This is my best try and it doesnt work:
Code:
<html><body>
<script language=javascript>

var myTable="<TABLE> <TR> <TD>1</TD> <TD>2</TD> </TR> <TR><TD>3</TD>
<TD>4</TD></TR> </TABLE>"
document.writeln("Hello World!");
document.writeln(myTable);
function f()
{
var
w=window.open('','','toolbar=no,scrollbars=no,width=200,height=150')
w.document.open('application/vnd.ms-excel','replace');
w.document.writeln(myTable);
w.document.close();
}
</script>

<A href="" onClick="document.write('reloading...');">reload</A>
<A href="" onClick="f();return false;">xls</A>

</body></html>
 
B

Bruce Wisentaner

Is there any way whatsoever to manipulate the MIME content-type at the
server-side? My goal is to redisplay a (very large) html table with
the "Content-Type:application/vnd.ms-excel" http header. This is to
avoid the need to re-download the data which is already there.

This is my best try and it doesnt work:
Code:
<html><body>
<script language=javascript>

var myTable="<TABLE> <TR> <TD>1</TD> <TD>2</TD> </TR> <TR><TD>3</TD>
<TD>4</TD></TR> </TABLE>"
document.writeln("Hello World!");
document.writeln(myTable);
function f()
{
var
w=window.open('','','toolbar=no,scrollbars=no,width=200,height=150')
w.document.open('application/vnd.ms-excel','replace');
w.document.writeln(myTable);
w.document.close();
}
</script>[/QUOTE]

[ SNIPPED]

Yes, you can set the content-type header at the server, but then the
message you send is not treated as HTML by the browser, it is treated
as MS-EXCEL, so then Javascript won't work (until MS-Excel  interprets
Javascript.) I suppose you could try embedding an MS-Excel macro, but
that should run afoul of security settings.

Why do you need to redisplay data already there?
If the data is changing in real-time on the server, that calls for
AJAX techniques (and more DOM access), amply covered elsewhere.
If you are manipulating data on the client, then you can use DOM
access and Javascript methods to redo the rows.

---Bruce Wisentaner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top