More in this section

Forums / Developing with Sitefinity / Help! Link to javascript file at page level

Help! Link to javascript file at page level

3 posts, 0 answered
  1. fibx
    fibx avatar
    4 posts
    Registered:
    18 May 2007
    20 Feb 2009
    Link to this post
    I use Sitefinity 3.6 for .net 3.5 and I want to add my javascript file that only used on a specific page. At Add Head Tags of the page I add a link, set type to "text/javascript" and href to "/scripts/test.js". But the link was rendered as "<link href="/scripts/test.js" type="text/javascript" />". I want it to be rended as "<script type="text/javascript" src="/scripts/test.js"></script>". How can I accomplish this goal?
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    20 Feb 2009
    Link to this post
    Hi fibx,

    We would suggest you use JsFileLink control which is provided by Sitefinity. This control displays link to a JS file in the head section of the page. To use it you need to do the following:
    1. Add JsFileLink control to Add Controls toolbox:

    <toolboxControls> 
            <clear /> 
            <add name="JsFileLink" section="Custom" type="Telerik.Cms.Web.UI.JsFileLink, Telerik.Cms.Web.UI" /> 

    2. Drag and drop the control into the page.
    3. Click Edit to open property window.
    3. Expand section File Link and set FileName property to point to the .js file (for example: ~/Sitefinity/Admin/ControlTemplates/Permissions.js).

    Do let us know if this helps.

    All the best,
    Pepi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. fibx
    fibx avatar
    4 posts
    Registered:
    18 May 2007
    23 Feb 2009
    Link to this post
    Pepi,

    Thank you. JsFileLink control works fine.
Register for webinar
3 posts, 0 answered