ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Javascript is not working in expression engine

January 27, 2012 5:46am

Subscribe [3]
  • #1 / Jan 27, 2012 5:46am

    Javascript is not working in expression engine, though on empty web page ( not expression engine) it is working properly.

    Even the most simple ones like this are not working.

    <head>
    [removed][removed]
    <style type=“text/css”>
    <!—
    .togblock {
    display:none;
    text-align:inherit
    }
    —>
    </style>
    [removed]
    $(document).ready(function() {$(’#toglink0’).click(
    function() {
    if ( jQuery.browser.msie && parseInt(jQuery.browser.version) == 6) {
    if ($(’#togblock1’).css(“display”)==“block”) {$(’#togblock0’).css(“display”, “none”);
    } else {$(’#togblock0’).css(“display”, “block”);
    }
    } else {$(’#togblock0’).toggle(“slow”);
    }
    if ($(’#toglink0’).text()==‘open…’) {$(’#toglink0’).text(’...close’);
    } else {$(’#toglink0’).text(‘open…’);
    }
    });
    });
    [removed]
    </head>
    <body>
    void(0)” id=“toglink0”]open…
    <div class=“togblock” id=“togblock0”>
    Text inside!!!
    </div></body>


    What can be problem.

  • #2 / Jan 27, 2012 12:51pm

    Philip Zaengle

    293 posts

    Take a look at what expressionengine is actually outputting, my guess is that curly brakets are being stripped out. For this reason I almost always store my JS in a non-EE template file.

    You also have the option of turning the protect javascript global config variable to true: http://ellislab.com/expressionengine/user-guide/general/hidden_configuration_variables.html#protect-javascript

  • #3 / Jan 29, 2012 7:46am

    Sean C. Smith

    3818 posts

    Hi .(JavaScript must be enabled to view this email address),

    I’m sorry you are having trouble with javascript. Philip has basically said what I was going to say. If you are storing your javascript ExpressionEngine templates then you’ll need to either turn on the protect javascript global config or move the js out of the template engine and call it in the head of your page like you normally would.

    Please get back to me and let me know if this resolves your situation.

    Sean

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases