Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bjerner 2 posts 22 karma points
    Feb 06, 2011 @ 17:43
    Bjerner
    0

    JavaScript not working in the Content Section

    I am trying to insert at little script on my webpage, by inserting it under HTML on the Content tab in the Content Section.

    The script could look like:
       <script type="text/javascript">document.write("test test");</script>

    But umbraco changes it to:
       <!-- document.write("test test"); // -->

    I am using umbraco v 4.0.3.

     

    Why are umbraco changing my script?

    And how do I get it to work?

     

    Best Regards
    Bjerner

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Feb 06, 2011 @ 17:53
    Chris Houston
    0

    Hi Bjerner,

    I guess the first question is why are you trying to add a script tag in the content section?

    Normally the content section is reserved for purely content ( i.e. editable by a non-techie ) so I would definitely advise trying to avoid adding any script in that section.

    You should add your script tags to your templates ( master pages ) or if you need to make them dynamic, the best way would be to include an XSLT macro and add your script instruction in the macro.

    Cheers,

    Chris

  • Bjerner 2 posts 22 karma points
    Feb 06, 2011 @ 22:30
    Bjerner
    0

    I was trying to create a script to obfuscated e-mail-address to avoid that they are crawled by spam robots.

    And I didn't see any reason to use a lot of time creating XSLT macros, when the HTML editor was available.

    Can it easily be done by XSLT?

     

    Best Regards
    Bjerner

  • Christer Josefsson 55 posts 93 karma points
    Feb 07, 2011 @ 22:09
    Christer Josefsson
    0

    Read this. Use contact forms with some CAPTCHA tech instead of obfuscating email addresses.

  • Ulu Honolulu 32 posts 61 karma points
    Apr 16, 2011 @ 16:32
    Ulu Honolulu
    0

    Sometimes you need a script that makes sense in a context of a single page. Creating a separate macro or template is both a waste of time and a problem for maintainability. For example, if a script references a particular element on the page, clearly you would want to keep this script somewhere close to that element, not in a separate file. I'd vote for making this configurable.

  • Ulu Honolulu 32 posts 61 karma points
    Apr 16, 2011 @ 16:50
    Ulu Honolulu
    0
    1. Modify the TextPage document type, add a Script property and set multiline text editor for it. Now you can edit your script in a separate field.
    2. In your template, add something like this:

        <script type="text/javascript">
          <umbraco:item runat="server" field="script">umbraco:item>   
        script>
Please Sign in or register to post replies

Write your reply to:

Draft