Is there any way I can change the content type when I open a new window
other than opening a script in the open statement?
mywin =
window.open('', 'rpt','width=60 0,height=425,to p=50,left=0,scr ollbars=yes,too lbar=yes,resiza ble=yes,depende nt=no');
mywin.document. write("Content-type:image/svg+xml");
In this example I would be changing the content type to svg.
I tried this and it did not work.
The window gets opened up as html.
Any help is appreciated.
Mike 5 15383
mike wrote: Is there any way I can change the content type when I open a new window other than opening a script in the open statement?
mywin = window.open('', 'rpt','width=60 0,height=425,to p=50,left=0,scr ollbars=yes,too lbar=yes,resiza ble=yes,depende nt=no');
Some browsers support data: URLs
(<http://www.faqs.org/rfcs/rfc2397.html>) so you can try your luck with e.g.
var win = window.open(
'data:applicati on/xhtml+xml,' + encodeURICompon ent([
'<html xmlns="http://www.w3.org/1999/xhtml">',
'<head>',
'<title>Example </title>',
'<script type="text/javascript">',
'window.onload = function (evt) {',
' alert(\'Content-Type: \' + document.conten tType + ',
' \'; \' + document.docume ntElement.tagNa me);',
'}',
'</script>',
'</head>',
'<body>',
'<p>Kibology for all.</p>',
'</body>',
'</html>',
].join('\r\n')),
'jsTest'
);
With Mozilla 1.7 that shows the content type application/xhtml+xml and
the tag name as lower case 'html' so there the markup is indeed treated
as XHTML.
Opera 8.50 also seems to parse as XHTML, it does not expose a
contentType property to check that but the tag name is 'html in lower
case. Also when I try to pass in not well-formed stuff it gives an XML
parse error.
With a Firefox 1.5 beta nightly I can do
var win = window.open(
'data:image/svg+xml,' + encodeURICompon ent([
'<svg xmlns="http://www.w3.org/2000/svg">',
'<script type="text/javascript">',
'window.onload = function (evt) {',
' alert(\'Content-Type: \' + document.conten tType + ',
' \'; \' + document.docume ntElement.tagNa me);',
'}',
'</script>',
'<circle cx="100" cy="100" r="20" fill="green" />',
'</svg>'
].join('\r\n')),
'jsTest'
);
as well and get the graphics rendered and the script shows the proper
values.
Opera 8.50 also renders the SVG graphics. Script in SVG is not supported
at all in that browser so the script in the SVG does not work there.
Keep in mind that I have never tested whether there are issues with
longer data URLs with long, complex markup.
mywin.document. write("Content-type:image/svg+xml");
In this example I would be changing the content type to svg.
In Netscape 4 you were supposed to do e.g.
mywin.document. open('image/svg+xml')
but other browsers have never supported that really. Mozilla 1.5 should
have some support for a limited set of content types e.g. you could do
mywin.document. open('text/plain')
but as far as I know there are no plans to support document.write for
stuff that would then go into an XML parser.
IE 6 seems to support open('text/plain') as well. Opera 8.50 does not
support that.
So document.write will probably not work for image/svg+xml, you could
start setting up a simple SVG document with a data: URL as shown above
and then it should be possible to add nodes using the DOM.
--
Martin Honnen http://JavaScript.FAQTs.com/
Thanks Martin, very useful ....
Martin,
I tried that in IE and it barfed all over me.
Mike
mike wrote: I tried that in IE and it barfed all over me.
The only thing that I suggested that works with IE 6 is
var win = window.open('', 'windowName');
win.document.op en('text/plain');
win.document.wr ite('Line1\r\nL ine2');
win.document.cl ose();
If you tried data: URLs with IE then sorry, I said some browsers support
data: URLs, as far as I know IE/Win does not support them at all (e.g.
not even statically in an HTML document with <img
src="data:image/gif,...">) so hoping that doing window.open with a data:
URL in IE/Win works is not fruitful.
In my understanding if you want to have content type like image/svg+xml
rendered that IE does not handle itself but which are handled by plugins
then you need to have a file: or http: or ftp: URL, there is no way to
have script pump in data into a window with document.write which is then
handled by a plugin.
--
Martin Honnen http://JavaScript.FAQTs.com/
Martin, Thanks again, Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bryan Feeney |
last post by:
I'm working on a site which dynamically generates tables of rates in CSV
format. The script which does the work is called generate_stats.php. Here's
the header
header ("Content-type: application/octet-stream");
header ("Content-Disposition: attachment; filename=query-results.csv");
header ("Pragma: no-cache");
header ("Expires: 0");
Now...
|
by: Unigroup of New York |
last post by:
Content-Type: multipart/mixed;
boundary="------------C465DF38DCB38DD2AF7117E0"
Lines: 327
Date: Tue, 15 Feb 2005 23:36:38 -0500
NNTP-Posting-Host: 24.46.113.251
X-Complaints-To: abuse@cv.net
X-Trace: fe12.lga 1108528794 24.46.113.251 (Tue, 15 Feb 2005 21:39:54 MST)
NNTP-Posting-Date: Tue, 15 Feb 2005 21:39:54 MST
Xref:...
|
by: Åženol Akbulak |
last post by:
Hi,
I have a form page to print on my web application(asp.net). I want to show
the page in WORD. I use that code in asp.net Page_Load event:
Response.Clear();
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition", "attachment;filename=word.doc");
When I open the page in IE shows a dialog to ask whether I...
|
by: Angelos |
last post by:
Hello there,
I am very new to Javascript and before I explain what I want I'll tell
you in a few words that I am trying to make a button on a WYSIWYG text
editor (RichArea) that previews on a template the content of the editor
and not in just an empty page.
I can't get around the folowing:
I have a page with a form and a text area. In...
|
by: bfiser |
last post by:
Good morning everyone. I have an issue with a page I developed using
ASP. On my page I have active (or is it dynamic) hyperlinks to photos
of employees based on their employee number. When I click on the
thumbnail in Internet Explorer I get a message box titled File Download
- Security Warning and it asks me to open or save if I click open...
| |
by: prasenjit2007 |
last post by:
I have a main form for inputing the (to/from/mesg/file) with the following code:-
<html>
<body>
<table>
<tr>
<td>To:</td>
<td><input type="text" name="to" size="50"
value="pras_sandilya@rediffmail.com"></td>
</tr>
|
by: lawrence k |
last post by:
I've got a music studio for a client. Their whole studio is run with
Macintosh computers. Macintosh computers allow file names to have open
white spaces, such as "animal hospital.mp3".
I have a download script, so customers on the website can download
MP3s to their harddrive (rather than merely listen to it in their
browsers):
|
by: JaxDawg |
last post by:
I have a spreadsheet saved as an XML spreadsheet so I can manipulate
it easier (and don't need COM). When I'm done, I want to display to
the user. Currently, I'm using simple JavaScript in my PHP file to
display the file when complete:
echo '<script type="text/javascript"window.open("'.$file_nm.'")</
script>';
Since the file is .XML,...
|
by: jerrygarciuh |
last post by:
Hi folks,
I have a PHP cron job that compiles a CSV from queries and emails it
to some clients. I have a complaint that one client can see the
indicating icon to say there is an attachment in his Apple Mail but
attempts to open it fail. If he forwards the email to Gmail he can
open the attachment from there so it is a mail client issue,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |