none
where does Javascript go in the code?

    Question

  • When I open my homepage to edit, some parts are not editible and I can add my code only to the PlaceHolderMain(Custom) section. That's okay. understandable..

    But then where can I add my javascript <script ... > code??

    The section open to me for editing is only this section here:
    <ZoneTemplate>
         <WebPartPages:DataFormWebPart runat="server" ...>
         </WebPartPages>
    </ZoneTemplate>

    And it seems that javascript code does not go inside <ZoneTemplate>section.. where's the right location?

    Any ideas will be very appreciated.
    Wednesday, November 04, 2009 5:27 PM

Answers

  • You can add a Content Editor Web Part and place your javascript in the Source Editor box of that web part. You can do this right from the browser.

    • Marked as answer by TMLP Thursday, November 05, 2009 7:45 PM
    Thursday, November 05, 2009 1:14 AM

  • Hi Loya,

    In PlaceHolderMain, you can either directly write the JavaScript code or refer JavaScript file.
    If you want to use some html's control in your JS then place your JS code after html code.

    <asp:Content ID="Content11" ContentPlaceHolderID="PlaceHolderMain" runat="server">
        <div>
        </div>
    
        <script type="text/javascript">
        </script>
    
        <script src="/_layouts/MyJavaScript.js" type="text/javascript" language="javascript"></script>
    
    </asp:Content>

    Regards, Avinash | avinashkt.blogspot.com
    • Marked as answer by TMLP Thursday, November 05, 2009 7:45 PM
    Thursday, November 05, 2009 9:42 AM

All replies

  • You can add a Content Editor Web Part and place your javascript in the Source Editor box of that web part. You can do this right from the browser.

    • Marked as answer by TMLP Thursday, November 05, 2009 7:45 PM
    Thursday, November 05, 2009 1:14 AM

  • Hi Loya,

    In PlaceHolderMain, you can either directly write the JavaScript code or refer JavaScript file.
    If you want to use some html's control in your JS then place your JS code after html code.

    <asp:Content ID="Content11" ContentPlaceHolderID="PlaceHolderMain" runat="server">
        <div>
        </div>
    
        <script type="text/javascript">
        </script>
    
        <script src="/_layouts/MyJavaScript.js" type="text/javascript" language="javascript"></script>
    
    </asp:Content>

    Regards, Avinash | avinashkt.blogspot.com
    • Marked as answer by TMLP Thursday, November 05, 2009 7:45 PM
    Thursday, November 05, 2009 9:42 AM