Click to See Complete Forum and Search --> : Problem with open opening popup


Andreas Schuth
05-31-2005, 02:07 AM
Hello Community,

I am kinda new to Java Script and I am facing an error I could not get rid of. It would be good if you guys could look the code up.

<script language="JavaScript" type="text/javascript">
<!--

if ( navigator.userAgent.toLowerCase().indexOf('mozilla') != -1 && navigator.userAgent.indexOf('5.') == -1 && navigator.userAgent.indexOf('6.') == -1 )

document.write('<img src="templates/subSilver/images/icon_hlsw.gif" alt=""/>');

else

document.write('
</td><td>&nbsp;</td><td valign="top" nowrap="nowrap">
<div style="position:relative"><div style="position:absolute">
<img src="templates/subSilver/images/icon_hlsw.gif" onclick="window.open('http://buddylist.hlsw.org/info.php?id=12345','_blank','width=160,height=120');" title="HLSW: 12345" border="0" alt=""/>
</div><div style="position:absolute;left:3px;top:-1px">
<img src="http://buddylist.hlsw.org/image.php?id=12345&img=1" width="14" height="14" onClick="window.open('http://buddylist.hlsw.org/info.php?id=12345','_blank','width=160,height=120');" border="0" alt=""/>
</div></div>
');

//-->
</script>

The Problem I face is that the ' and the // of the hyperlink wont work. Is there an escape character for that?

Any help is really appreciated.

Cheers,

Andreas

BigMoosie
05-31-2005, 03:16 AM
\' will escape that character for you ;), as well as for \", also note that to create a new line (not html <BR> but actual new line feed in the code) you can use \n.

Andreas Schuth
05-31-2005, 03:33 AM
Thank you.
in the line:

document.write('....');

do I have to escape all ' and " ?

Cheers,

Andreas

BigMoosie
05-31-2005, 03:40 AM
No no, just the '.

But occasionally you may use document.write("...") if what you are writing has lots of ', in that case the only ones to escape are the ".

Also note that if you are writing tags then it is best to escape the / with a \ so use document.write('<\/b>');. That is not entirely neccessary but is very important if you are writing a closing script tag.

Andreas Schuth
05-31-2005, 06:20 AM
Yes !
Its working now :-)
Thank you very much.

Andreas