[TYPO3] template and Javascript problem
Franz Holzinger
franz at fholzinger.com
Sat Sep 1 14:05:34 CEST 2007
Hello Cray,
>
> I have some problem with javascript in tempate. I have such button code
> in my template:
>
> <!--LiveInternet counter--><script type="text/javascript"><!--
> document.write("<a href='http://www.liveinternet.ru/click' "+
> "target=_blank><img src='http://counter.yadro.ru/hit?t44.4;r"+
> escape(document.referrer)+((typeof(screen)=="undefined")?"":
> ";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
> screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+
> ";"+Math.random()+
> "' alt='' title='LiveInternet' "+
> "border=0 width=31 height=31><\/a>")//--></script><!--/LiveInternet-->
> =========================
>
>
> But when I look in the browser's "View source code..." I see really
> strange thing:
>
> =========================
> <!--LiveInternet counter--><script type="text/javascript"><!--
> document.write("<a href="http://www.liveinternet.ru/click"
> target="_blank"><img src="http://counter.yadro.ru/hit?t44.4;r"+
> escape(document.referrer)+((typeof(screen)=="undefined")?"":
>
> ";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?
>
> screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+
> ";"+Math.random()+
> "" alt="" title="LiveInternet" border="0" width="31" height="31"
> /><\/a>")//--></script><!--/LiveInternet-->
>
> </a>
> =========================
>
> So it changes " to " and writes </a> in the end. I can't understand
> what I have to do. Can anybody help me with it? Any suggestions? Or I
> need to forget about it and insert it with TS?
In your example you did not escape your quotes.
document.write.(" opens a quote. But you cannot use the same " inside of
it! This must be escaped. \"
There is a similar bug of TYPO3 since 2005.
http://bugs.typo3.org/view.php?id=1477
Please test these patches.
I hope this will be fixed in TYPO3 4.2.
- Franz
More information about the TYPO3-english
mailing list