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=600,height=425,top=50, left=0,scrollbars=yes,toolbar=yes,resizable=yes,de pendent=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 15372
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=600,height=425,top=50, left=0,scrollbars=yes,toolbar=yes,resizable=yes,de pendent=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:application/xhtml+xml,' + encodeURIComponent([
'<html xmlns="http://www.w3.org/1999/xhtml">',
'<head>',
'<title>Example</title>',
'<script type="text/javascript">',
'window.onload = function (evt) {',
' alert(\'Content-Type: \' + document.contentType + ',
' \'; \' + document.documentElement.tagName);',
'}',
'</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,' + encodeURIComponent([
'<svg xmlns="http://www.w3.org/2000/svg">',
'<script type="text/javascript">',
'window.onload = function (evt) {',
' alert(\'Content-Type: \' + document.contentType + ',
' \'; \' + document.documentElement.tagName);',
'}',
'</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.open('text/plain');
win.document.write('Line1\r\nLine2');
win.document.close();
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:...
|
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...
|
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 =...
|
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...
|
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...
|
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"
...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
| |