RE: Javascript string problem

by Klaas De Waele <klaas(at)gracegraphics.be>

 Date:  Fri, 3 Aug 2001 12:16:52 +0200
 To:  "'Brian Blackett'" <bwblackett(at)yahoo.com>,
"'hwg-techniques(at)hwg.org'" <hwg-techniques(at)hwg.org>
  todo: View Thread, Original
Dear Brian,


the problem is very simple.

Take the line where you have the onClick defined.  Check what happens when
you use Link 2...

<.a href='#' onClick=Link 2>Click here<./a>

As you see, there's your problem: onClick=Link 2 has a space, which is okay
if it is enclosed between quotes.  You don't have quotes, so the 2 actually
doesn't belong to onClick anymore.

Here's the file... Please mind the linebreaks (-). I put some comment and
changed your caller function (you dont need the variable).

I'm sending it in an attachment to your personally (not dotted-out)



<.html>
-
<.head>
-
<.title>test<./title>
-
<.script language='JavaScript'>
-

function text(text)
-
{
-
infowin=open('','Picture','width=300,height=50,status=no,toolbar=no,menubar=
no');
-
infowin.document.open();  //can be left out
-
infowin.document.write('<.html><.head><.title>You\'ve clicked
it<./title><./head><.body onLoad=self.focus();>' + text +
'<.br><./body><./html>'); //mind the complete html structure
-
infowin.document.close();
-
}
-
function caller(text)
-
{
-
return "<.a href='#' onClick=\"text('"+text+"');\">Click here<./a><.br>"
-
// you don't need the variable originally declared.
-
}
-
<./script>
-
<./head>
-
<.body>
-
<.script language='JavaScript'>document.write(caller('Link1'))<./script>
-
<.script language='JavaScript'>document.write(caller('Link 2'))<./script>
-
<./body>
-
<./html>



-----Oorspronkelijk bericht-----
Van: owner-hwg-techniques(at)hwg.org
[mailto:owner-hwg-techniques(at)hwg.org]Namens Brian Blackett
Verzonden: vrijdag 3 augustus 2001 10:22
Aan: hwg-techniques(at)hwg.org
Onderwerp: Re: Javascript string problem


Sorry folks, my email program messed up the formatting
of the file I sent.

The two script lines should be like below i.e. no
newline characters.

<script>document.write(caller('link1'))</script>
<script>document.write(caller('link 2'))</script>

The problem is with the space between the word link
and the number 2 in the second line.

Any help appreciated.

Brian
www.blackettwebsitebuilders.net

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA

This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.