stefano said:
I have a xml document that generate a XHTML document using XSLT. in
this document there are some span element (that contain image, text,
ecc) that are hidden. when I click on some other elements, the content
of a particular span tha was hidden should appear on a new window. The
code of the onclick method I write is:
.
.
var content=document.getElementById("content"); //the content of a
hidden span
var s=content.innerHTML;
Are you aware that .innerHTML does not return the actual element content
but what the UA could render of it? Especially it will be _HTML_, not
XHTML.
var win =
window.open("","debug","width=500,height=300,modal,dialog,resizable");
Thank you for pointing out the `modal' and `dialog' features I did not know
about yet. Note however, that without the UniversalBrowserWrite privilege
`modal' is equivalent to `dependent'.
win.document.write(s);
win.document.close();
You missed win.document.open() before the .write().
<URL:
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-72161170>
However, that would still not write any markup to the popup's document.
There is no XML Processing Instruction, no DOCTYPE declaration, no root
element and no container element. So nothing that the stylesheet's
selectors can match reliably.
You are looking for something similar to the following:
<!-- assuming this is XHTML -->
<script type="text/javascript">
<![CDATA[
...
// to create an HTML document
win.document.write([
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
' "
http://www.w3.org/TR/html4/strict.dtd">',
'<html>',
' <head>',
' <meta http-equiv="Content-Type"'
+ ' content="text/html; charset=iso-8859-1">',
' <title>meaningful title</title>',
' <link rel="stylesheet" href="
http://example.com/x.css"'
+ ' type="text/css">',
' </head>',
' <body>',
' <div><img src="image.gif" alt="alternative content">'
+ s
+ '</div>',
' </body>',
'</html>'
].join("\n"));
// to create an XHTML document
win.document.write([
'<?xml version="1.0" encoding="iso-8859-1"?>',
'<?xml-stylesheet href="
http://example.com/x.css" type="text/css"?>',
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
' "
http://www.w3.org/TR/xhtml1/dtd/xhtml1-strict.dtd">',
'<html>',
' <head>',
' <title>meaningful title</title>',
' </head>',
' <body>',
' <div><img src="image.gif" alt="alternative content">'
+ s
+ '</div>',
' </body>',
'</html>'
].join("\n"));
...
]]>
</script>
(As you can see there is no need for escaping markup delimiters if you
declare the content of the XHTML `script' element as CDATA. However, it
is recommended to use script elements in XHTML as include only, where you
would not need to declare or escape anything.)
It is important that you specify the full URL of the stylesheet because
the generated content has no (reliable) domain.
HTH
PointedEars