[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Background color problem with dynamic XSL


Subject: Re: [xsl] Background color problem with dynamic XSL
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Mon, 16 Jul 2001 18:04:32 -0400

I'm on Win2000, IE5.5, recent upgrade, msxml3 in replace mode (which
shouldn't affect my html example, of course).  I have no ideas on why you
didn't get the same result as me when you copied my HTML example!  See if
there is an IE upgrade you can install.  My IE version is

5.50.4522.1800

I hate to ask it, but did you copy my code sample **exactly** when it didn't
work?

Here's what I think might happen with your javascript, though, bearing in
mind that apparently you can only set the document's background color before
the entire document has been completely loaded.

You write the document from a string (created from the xslt transformation).
Then:

> top.rightTop.document.write(str);
> top.rightTop.document.close();
> top.rightTop.document.bgColor = "silver";

I think that this is just like my experiment to change the color after the
document is loaded - and it likewise would fail.  I bet this variation would
work:

 top.rightTop.document.write(str);
 top.rightTop.document.bgColor = "silver";
 top.rightTop.document.close();

I'm assuming that this would be equivalent to setting the color in the
"onLoad" event, but I'm not sure of that.  Of course, if you are going to
create the html as a string, you can just as well put a background color
into the body element when you create the string.

I suggest you simplify this problem to work on it.  Create two frames, or
have your first document open a second window. Write an html string to the
other window, and see what it takes to get it to change color or at least
set the color when it loads.  When that works to your satisfaction, then try
to duplicate the string exactly in a transform and write it to your window
as you have tried to do here.  If it still works differently, then you would
know that using these XML COM  objects causes some difference in how the
browser renders HTML.

It ought to be possible to change the background color by scripting the
style properties.  I haven't tried it, but you might want to.

Cheers,

Tom P

[<richard.whitley@xxxxxxxxxxxx>]

[Tom Passin]
> >
> > Here's what I did:
> >
> > <html>
> > <head>
> > <script language='javascript'>
> >
> > function changecolor(){
> >  document.bgColor='silver'
> > }
> >
> > </script>
> > </head>
> >
> > <body onload='changecolor()'>
> > <h3>This is a test of dynamically setting the document bgcolor</h3>
> >
> > </body>
> > </html>
> >
> > Tom P
> >
> >
> >
>
> Thanks for the idea, Tom.  Even this doesn't work for me (in IE 5.5.)  I'm
now really curious for why it works for you, but not for me.  What OS are
you using?  I'm on NT 4.0.
>
> In addition to calling the internal script from the onload event, as you
did, I also tried setting the property from within the external JS file that
creates the page.  Here's what I used:
>
> ...
> var xslDoc = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
> var xmlDoc = new ActiveXObject("MSXML2.DOMDocument");
>
> xslDoc.async = false;
> xslDoc.load(xslFile);
>
> xmlDoc.async = true;
> xmlDoc.load(xmlFile);
>
> var tem = new ActiveXObject("MSXML2.XSLTemplate")
> tem.stylesheet = xslDoc;
> var proc = tem.createProcessor();
> proc.addParameter(paramName, paramVal);
> proc.input = xmlDoc;
> proc.transform();
> var str = proc.output;
> alert(str);
> top.rightTop.document.write(str);
> top.rightTop.document.close();
> top.rightTop.document.bgColor = "silver";
> ...
>
> I tried changing bgColor both before and after I call close on the
document object.  It doesn't work either way.  Of course, I removed the
onload event handler from the BODY element in the XSLT before trying this.
>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords