473,769 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

import stylesheet

Hi all, I hopen a new empty window from js code:
var win =
window.open("", "debug","width= 500,height=300, modal,dialog,re sizable");
and I add some element to the new window:
win.document.wr ite("<img src="image.gif& gt;");
win.document.wr ite.....

How can I add the stylesheet information of the file x.css
(how and where I must write in the new window the line:
<?xml-stylesheet href="x.css" type="text/css"?> )

thanks

Feb 9 '06 #1
7 2046
VK

stefano wrote:
Hi all, I hopen a new empty window from js code:
var win =
window.open("", "debug","width= 500,height=300, modal,dialog,re sizable");
and I add some element to the new window:
win.document.wr ite("&lt;img src="image.gif& gt;");
win.document.wr ite.....
Which produces a very strange chunk of code of kind of:

<HTML>
&lt;img src="image.gif& gt;
</HTML>

<HTML> pair is still being added automatically as NN 3.0 thaught
everyone
&lt; and &gt; are being sent as it is, they are not converted into < >

Obviously there is neither place not sense to add a style sheet into
_it_
How can I add the stylesheet information of the file x.css
(how and where I must write in the new window the line:
<?xml-stylesheet href="x.css" type="text/css"?> )


You want to do something - you do it good.

1) Create and save file named blank.html in the most primitive form:
<html>
<head>
<title>Debugger </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
</head>
<body>&nbsp;</body>
</html>

2)
var win =

window.open("bl ank.html","debu g","width=500,h eight=300,resiz able=yes");

with (win.document) {
clear();
open('text/html');
write('<html><h ead><title>Debu gger</title>');
write('<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">');
// here it goes now:
write('<link rel="stylesheet " href="my.css">' );
write('</head><body>');
// anything you want to add into your page:
write(MyPageCon tent);
write('</body></html>');
close()
}

Overall ever since NN 4.x is gone such "from A to Z" usage of
document.write is unnecessary complicated way IMHO. It is easier to
load a page-template and change its parts using DOM methods. Up to you
anyway.

Feb 9 '06 #2
My code come from XSLT and the content of the new window is more than
one image (I can have also text, animation and sound (embed element)).
I can't create and save a file for the scope of the application I'm
working on.
I can't use DOM method because I have a lot of problem with IE (strange
things appens. For example a and b are two sibling but a.paretNode is
different of b.parentNode). I need just to add stylesheet information
if is possible in this way.

Feb 9 '06 #3
VK

stefano wrote:
My code come from XSLT and the content of the new window is more than
one image (I can have also text, animation and sound (embed element)).
I can't create and save a file for the scope of the application I'm
working on.
I can't use DOM method because I have a lot of problem with IE (strange
things appens. For example a and b are two sibling but a.paretNode is
different of b.parentNode). I need just to add stylesheet information
if is possible in this way.


Unfortunately it is not possible. document.write( ) clears the previous
content if used after load event. And you cannot use it before load
because for that you need to have document.write( ) statements in the
loading page itself.
If you cannot use DOM then you cannot do it at all.
So the only option is to decide which "can't" you have to change to "I
don't like it but I have to" :-)

I would try DOM first, specially because IE has the least problem with
it, it even has a whole special method createStyleShee t for you.

Try:
win.document.cr eateStyleSheet( 'myStyles.css') ;

P.S. I'm suspitious about XSLT you mentioned. The page you open is not
XML+XSLT combo by any chance?

Feb 9 '06 #4
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=documen t.getElementByI d("content"); //the content of a
hidden span
var s=content.inner HTML;
var win =
window.open("", "debug","width= 500,height=300, modal,dialog,re sizable");
win.document.wr ite(s);
win.document.cl ose();

Feb 9 '06 #5
stefano wrote:
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=documen t.getElementByI d("content"); //the content of a
hidden span
var s=content.inner HTML;
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,re sizable");
Thank you for pointing out the `modal' and `dialog' features I did not know
about yet. Note however, that without the UniversalBrowse rWrite privilege
`modal' is equivalent to `dependent'.

<URL:http://developer.mozil la.org/en/docs/DOM:window.open >
win.document.wr ite(s);
win.document.cl ose();


You missed win.document.op en() 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.wr ite([
'<!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>meaningf ul title</title>',
' <link rel="stylesheet " href="http://example.com/x.css"'
+ ' type="text/css">',
' </head>',
' <body>',
' <div><img src="image.gif" alt="alternativ e content">'
+ s
+ '</div>',
' </body>',
'</html>'
].join("\n"));

// to create an XHTML document
win.document.wr ite([
'<?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>meaningf ul title</title>',
' </head>',
' <body>',
' <div><img src="image.gif" alt="alternativ e 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
Feb 10 '06 #6
Thomas 'PointedEars' Lahn wrote:
// to create an XHTML document
win.document.wr ite([
'<?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>',


Argl. I forgot the namespace and stuff. The last quoted line should be
more like

'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"'
+ ' lang="en">',
PointedEars
Feb 10 '06 #7
I try this:
<xsl:attribut e name="onclick"> javascript:
..
..
var content=documen t.getElementByI d("mycontent" );
var s=content.inner HTML;
var loc=window.loca tion.toString() .replace(/\/([^\/])*xml/,"");
var win =
window.open("", "debug","width= 500,height=300, modal,dialog,re sizable");
var lll=loc+"x.css" ;
win.document.op en() ;
win.document.wr ite(
'&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;' +
'&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/dtd/xhtml1-strict.dtd"&gt; '
+
'&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"' + '
lang="en"&gt;' +
' &lt;head&gt; '
+
'&lt;title&gt;m eaningful title &lt;/title&gt;'+
'&lt;link type="text/css" rel="stylesheet " href=' +lll +" "+'/&gt;'+
' &lt;/head&gt;'
+
' &lt;body&gt; '+
' &lt;div&gt;'
+ s
+ '&lt;/div&gt;'
+
' &lt;/body&gt;'
+
'&lt;/html&gt;'
);
win.document.cl ose();
..
..

and also this:
<xsl:attribut e name="onclick"> javascript:
..
..
var content=documen t.getElementByI d("mycontent" );
var s=content.inner HTML;
var loc=window.loca tion.toString() .replace(/\/([^\/])*xml/,"");
var win =
window.open("", "debug","width= 500,height=300, modal,dialog,re sizable");
var lll=loc+"x.css" ;
win.document.op en() ;
win.document.wr ite(
'&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;' +
'&lt;?xml-stylesheet href='+lll +' '+ 'type="text/css"?&gt;' +
'&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/dtd/xhtml1-strict.dtd"&gt; '
+
'&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"' +
' lang="en"&gt;' +
' &lt;head&gt; '
+
' &lt;title&gt;me aningful title &lt;/title&gt;'+
' &lt;/head&gt;'
+
' &lt;body&gt; '+
' &lt;div&gt;'
+ s
+ '&lt;/div&gt;'
+
' &lt;/body&gt;'
+
'&lt;/html&gt;'
);

win.document.cl ose();
but the stylesheet information of the file x.css are not applied to the
new window.
help please
thanks

Feb 10 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2093
by: Shiju Rajan | last post by:
Hi, I have one transformation called transform1.xsl. transform1.xsl <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import href="transform2.xsl"/> <xsl:output method="xml"/> ------------------------------------------- <xsl:apply-imports/> -------------------------------------------
1
2221
by: bjam | last post by:
Hi, today I was able to abstract out into a separate xsl file a template that I specifically perform a call templates for, this worked with import no problem. However, when trying to do the same operation with a template that I use a match template on, IE was giving me the following error for the style sheet. Does anyone know how to import or include a match template versus a call named template? Thanks in advance for your help The...
7
11810
by: steven | last post by:
Which one is better: <link rel="stylesheet" href="style.css" type="text/css" /> or <style type="text/css"> @import url("style.css"); </style>
0
2150
by: atlantis | last post by:
Hi, I have a very strange problem with xsl:import when usig RELATIVE path on AIX 5.2 server. I have two XSL files in the same directory: "ists_xslt3.xsl" and "ists_xslt3_layout.xsl". This is what the beginning of "ists_xslt3.xsl" looks like:
2
3228
by: Keith Chadwick | last post by:
I have been running some tests with regards to xsl:include and xsl:import with the same results on both and I am wondering if someone can explain this behavior to me! First off the xslt file is being loaded as in dim myXSLT as new XslTransform() myXSLT.load("scripts/clnt.home.body.xslt") The load craps out when I change the xsl:include, tried all of the following
3
1516
by: teranews | last post by:
My question is this... Is 'LINK'ing a stylesheet required before 'IMPORT'ing another for successful hovering? I have a problem which cropped up with the introduction of IE 7 Beta 2... Yes.. I realize it's IE (strike one)... and it's Beta (strike two)... but ALL the hovering on my web site doesn't work in IE 7 B2 ! ! !
2
4089
by: alex.iskold | last post by:
Hi, i am having the following problem: A style sheet imports another stylesheet: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:include href="common.template"/> ..... </xsl:stylesheet>
2
2370
by: flamingmo | last post by:
Hi Everyone, it's my first post, so please be kind... :-) I've had a look through the board and although CSS importing has been covered in quite a few topics, I have what I think is a unique challenge, which is to import a specific stylesheet depending on the class set in my body tag. Let me explain. I am using the usual <link> tag to import my "screen" stylesheet into each of my pages. This provides basic structure and formatting,...
1
2926
by: Praveen | last post by:
Have a common function in Javascript which do transform for all .xsl's. XSL object is loaded like this. var xslobj=new ActiveXObject("MSXML2.FreeThreadedDOMDocument.4.0"); xslobj.async = false; xslobj.load(xslpath); Here inserting an 'xsl:import' node to the xsl before doing transform. This xsl contains some common templates which can be used across all xsl's. So no need of doing import of this specifically in all xsl's.
15
8615
by: maxin | last post by:
Hi, I write a javascript function in xsl (UOMConversion.xsl) as follow: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <script language="Javascript"> <!) { UOMOut = MESUOM;
0
9589
marktang
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9994
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.