[Javascript] Wacky unterminated string + alert + IFRAME error....

Craig Michael Nathan cnathan at MEconomy.com
Mon May 7 16:24:26 CDT 2001


In this latest rev, yes -- I accidentally left a ">"
from the quoted response.  The actual line is (with
e-mail added line breaks):

ilSrc = 'javascript:document.write('+qt+'<script
language="JavaScript">alert("works!");</script>'+qt+');';


I tried the eval() trick, to no avail.  I also tried
escaping the "/", as well as replacing it with a 
variable (var sl = '/';), but neither helped.


Any thoughts on why this happens when I don't have the
alert('isIE'); call, but doesn't when that call is
commented out?


	Thanks!

			-Craig


TomMallard wrote:
> 
> ilSrc = 'javascript:document.write('+qt+'<script>
> language="JavaScript">alert("works!");</script>'+qt+');';
> 
> Isn't there an extra > in the script tag?
> 
> <script> language="JavaScript">
> 
> ..that's probably it...if that's not it, my first reaction was that you
> need eval to write the line...
> 
> ilSrc = eval('javascript:document.write('+qt+'<script
> language="JavaScript">alert("works!");</script>'+qt+');
> 
> tom
> ----- Original Message -----
> From: "Craig Michael Nathan" <cnathan at MEconomy.com>
> To: <mallard at serv.net>
> Cc: <javascript at LaTech.edu>
> Sent: Monday, May 07, 2001 1:39 PM
> Subject: Re: [Javascript] Wacky unterminated string + alert + IFRAME
> error....
> 
> > If I comment out the "// alert ('isIE!');"
> > line, then I get the error on the next line
> > (which is all on one line in the script, but E-Mail wraps....):
> >
> > ilSrc = 'javascript:document.write('+qt+'<script>
> > language="JavaScript">alert("works!");</script>'+qt+');';
> >
> > What's interesting is that if I remove the "/" from
> > the "</script>", it doesn't complain (but also doesn't
> > throw up the "works!" alert).
> >
> > Thanks!
> >
> > -Craig
> >
> >
> >
> > >From: "TomMallard" <mallard at serv.net>
> > >To: <javascript at LaTech.edu>
> > >Subject: Re: [Javascript] Wacky unterminated string + alert + IFRAME
> error....
> > >Date: Mon, 7 May 2001 06:59:43 -0700
> > >Organization: Individual
> > >Reply-To: javascript at LaTech.edu
> > >
> > >What line does the error message have without the alert in it?
> > >
> > >tom
> > >----- Original Message -----
> > >From: "Craig Michael Nathan" <cnathan at MEconomy.com>
> > >To: <javascript at LaTech.edu>
> > >Sent: Monday, May 07, 2001 12:50 AM
> > >
> > >
> > >
> > >From: "TomMallard" <mallard at serv.net>
> > >To: <javascript at LaTech.edu>
> > >Subject: Re: [Javascript] Wacky unterminated string + alert + IFRAME
> error....
> > >Date: Mon, 7 May 2001 06:59:43 -0700
> > >Organization: Individual
> > >Reply-To: javascript at LaTech.edu
> > >
> > >What line does the error message have without the alert in it?
> > >
> > >tom
> > >
> > >> Wacky unterminated string + alert + IFRAME error....
> > >>
> > >>
> > >> I have a page that embeds a remote javascript file.
> > >> That remote javascript file (MEchecker_test.js) creates
> > >> an IFRAME, and then attempts to write into it.
> > >>
> > >> When the remote javascript file includes an alert() function,
> > >> it works perfectly.  When I remove the alert() function,
> > >> I get an "unterminated string constant".
> > >>
> > >> I've tested in both IE 5.01 and 5.5, with the same results.
> > >>
> > >> Any ideas?
> > >>
> > >> Please respond to: cnathan at MEconomy.com
> > >>
> > >> Thanks!
> > >>
> > >> -Craig
> > >>
> > >>
> > >> *************** HTML *********************
> > >>
> > >> <html><head><title>Test</title><body>
> > >>
> > >> <script language="JavaScript1.2" src="MEchecker_test.js"></script>
> > >>
> > >> <h3>test</h3></body></html>
> > >>
> > >>
> > >> ********* Remote JavaScript (MEchecker_test.js) ***********
> > >>
> > >> document.write('<IFRAME ID="myIFRAME" WIDTH="0" HEIGHT="0"></IFRAME>');
> > >>
> > >> var qt = "'";
> > >>
> > >> function fillIFRAME() {
> > >>
> > >> // *** UNCOMMENT THIS NEXT LINE TO MAKE THIS SCRIPT WORK:
> > >>  // alert ('isIE!');
> > >> ilSrc = 'javascript:document.write('+qt+'<script
> > >> language="JavaScript">alert("works!");</script>'+qt+');';
> > >> document.all.myIFRAME.src = ilSrc;
> > >> }
> > >>
> > >> window.onLoad=fillIFRAME();
> >




More information about the Javascript mailing list