[TYPO3-english] page.jsInline strips parts of the JavaScript code

JoH asenau info at cybercraft.de
Tue Feb 8 11:35:39 CET 2011


Am 08.02.2011 11:00, schrieb Peter Kraume:
> I've added the following TypoScript with JavaScript code within an
> extension:
>
> page.jsInline {
> 4711 = TEXT
> 4711.dataWrap (
> window.fbAsyncInit = function() {
> FB.init({
> appId: '',
> status: true,
> cookie: true,
> xfbml: true
> });
> };
> (function() {
> var e = document.createElement('script'); e.async = true;
> e.src = document.location.protocol +
> '//connect.facebook.net/en_US/all.js';
> document.getElementById('fb-root').appendChild(e);
> }());
> )
> }
>
> The result in the frontend is broken:
>
> window.fbAsyncInit=function());};(function()());
>
>
> Obviously some parts of the JavaScript are stripped.
>
> It doesen't matter whether config.removeDefaultJS or config.minifyJS are
> enabled or disabled. TYPO3 version is 4.4.6
>
> Can someone confirm this issue?

This is a known issue which is a result of the TS syntax interfering 
with the JS syntax due to the braces. Both () and {} are part of the TS 
syntax and therefor you can not use them like in your example.

Since you don't really use the "data" funcitonality of dataWrap you 
could at least remove the problem with the curly braces by using 
4711.value instead. But still the multiline approach might not work as 
expected.

If you want to implement code like that, you should include an external 
JS file via FILE to get rid of these problems.

HTH

JOey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Xing: http://contact.cybercraft.de
Twitter: http://twitter.com/bunnyfield
TYPO3 cookbook (2nd edition): http://www.typo3experts.com


More information about the TYPO3-english mailing list