3

I need to be able to insert Javascript into a webpage via an Umbraco Document property. How do I do this?

1 Answer 1

2

Add a field to your document type with the type Textbox Multiple. Give it an appropirate alias like HeaderCode.

Add a reference to HeaderCode in your template.

<html>
    <head>
        ...
        <script type="text/javascript">
            <umbraco:Item runat="server" field="HeaderCode"/>
        </script>
    </head>
    ...
</html>

You can now enter your script into the HeaderCode, e.g.

 $(function() {
     // Stuff to do on page ready.
 });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.