PB : document.write some HTML code with <script src=".."> tags

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Sylvain Langlade (sylvain_at_adv-informatique.removethis.fr)
Date: 02/12/04


Date: Thu, 12 Feb 2004 18:09:35 +0100

Hi all,

I'm facing an IE6 strange behaviour. This is for a french IE6 SP1 with this
week patch installed.

I'm doing a script that should strip the current document to a printable
version. It is rather simple in concept :

take your original HTML code :

<html>
<head>
<script language="Javascript" src="/lib.js"></script>
</head>
<body>
<..... nice little GUI with tables, that breaks the printer page setup ....>
<div id="myInfo"><.... my content ...></div>
<..... end of the GUI ...>
</body>
</html>

Everything works fine. Transform it to

<html>
<head>
<script language="Javascript" src="/lib.js"></script>
</head>
<body>
<.... my content ...>
</body>
</html>

This part is OK, so I've got myself a variable with this new HTML code. I
open a blank popup window, copy the HTML code into it and... it breaks due
to errors in the javascript.

I've tried to debug this stuff, and it appears that the included javascripts
(there are 3 of them in the <head>, plus another one in "my content") are
the culprits. Well, IE6 is the real culprit : I'm a french coder, so I have
some accentuated chars in my comments and strings. And those chars are
defanged / mangled by IE when they are loaded within my on-fly created
document.

That's bad because my strings are mangled. But also because when such a char
is placed on the last position of a one-line comment, the following carriage
return does somehow disappear and generate syntax errors.

I tested the very same javascript function with Mozilla, it works like a
charm. Is there any way to tell IE to not mangle my code when inserting
javascript scripts in my new document. Like a locale setting for this
document ?

Thanks in advance.



Relevant Pages

  • Re: Javascript 101 - Calling a CGI script
    ... I have a CGI/Perl script that simply creates a few Javascript ... Now in my .html code I have TWO blocks where I call the code ... simply call the CGI script from WITHIN the second block above. ...
    (comp.lang.javascript)
  • Javascript 101 - Calling a CGI script
    ... I have a CGI/Perl script that simply creates a few Javascript ... Now in my .html code I have TWO blocks where I call the code ... simply call the CGI script from WITHIN the second block above. ...
    (comp.lang.javascript)
  • Re: any reason why this code example wont work?
    ... I've tried it in javascript, ... So all i want to do is call the getTime.aspx via the <script> tag and in its ... When i run it it does nothing except return me a javascript error saying: ... that does'n exist, cause default.aspx is at least html code, not ...
    (microsoft.public.dotnet.framework.aspnet)
  • Javascript what is need to do it in frontpage? and How do I determ
    ... javascript any tools or do I just write the script what do I have to do to ... Below is my radiobutton HTML code which would come well before the ...
    (microsoft.public.frontpage.programming)
  • Re: Decoding html pages
    ... the HTML code that the PHP engine produces *from* the raw html code and that ... That's the case with practically any PHP "page" (or any by a ... server-side script generated page for that matter). ... Of course the script does load, when you load the proper page (else it would ...
    (comp.lang.javascript)