+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / How to add javascript to a page?

How to add javascript to a page?

22 posts, 0 answered
  1. Kelly
    Kelly avatar
    5 posts
    Registered:
    30 Jul 2007
    02 Oct 2007
    Link to this post
    I didn't find any information in the documentation or the forums. Did I miss it?
    I tried to use the generic content control, but it seems to strip out any script tags.
    I could create a template with the javascript included for each version of necessary javascript includes, but that doesn't seem very practical. How can I go about including javascript from an external source and inline?

    Thanks
  2. bnye
    bnye avatar
    332 posts
    Registered:
    22 Sep 2005
    02 Oct 2007
    Link to this post

    Try changing the following property to true in the Sitefinity/Admin/ControlTemplates/EditorConfigFile.xml file:

    <property name="AllowScripts">true</property>


    I hopw that helps:

    Sincerely,

    Ben

  3. Kelly
    Kelly avatar
    5 posts
    Registered:
    30 Jul 2007
    03 Oct 2007
    Link to this post
    That did the trick. Is that (or related topic) documented anywhere?
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    08 Dec 2016
    03 Oct 2007
    Link to this post
    Hello Kelly,

    This is documented in the RadEditor online documentation. The AllowScripts property gets or sets the value indicating whether script tags will be allowed in the RadEditor content. It is true when the script tags are allowed in the RadEditor content; otherwise false. The default value is false.

    We have plans for the future to make a separate installation for Rad Controls documentation that will be accessible along with Sitefinity installation.

    Hope this is helpful.

    Kind regards,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Kevin Pipher
    Kevin Pipher avatar
    91 posts
    Registered:
    30 Nov 2005
    18 Oct 2007
    Link to this post
    Thanks for the solution Ben and Pepi. I also had this issue.

    If I may make one further suggestion - it would be nice to have a separate control to insert script (either inline javascript or javascript includes). I personally find it counter intuitive to have to add a generic content control, and then switch to code view and enter it there.

    I know I'm just being picky, but I would love to be able to drag and drop a "Client Script" control or something similar, where its properties would allow you to define either an src or paste inline code. Code coloring would also be fantastic.

    Just an idea anyway...

    Kevin
  6. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    19 Oct 2007
    Link to this post
    Hi Kevin Pipher,

    Thank you very much for the suggestion. We will consider implementing it in one of the upcoming releases.

    Best wishes,
    Slavo
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. briankb
    briankb avatar
    56 posts
    Registered:
    23 Feb 2004
    10 Mar 2008
    Link to this post
    Is it possible to handle this in code say in a on load?

    For instance we only want javascript enabled on a few pages. We could make another masterpage and use it for pages that require script. In the code behind of the master page on load event I could add the appropriate code to allow for scripts specifically for that page.

    Is this possible?
  8. Tihomir
    Tihomir avatar
    53 posts
    Registered:
    24 Sep 2012
    11 Mar 2008
    Link to this post
    Hi Brian,

    I will reveal a small hidden feature of Sitefinity 3.2 that should be useful to you in your case.

    Sitefinity 3.2 adds 2 small controls which allow you to add JavaScript or CSS easily (in 3.2 not so intuitive though) to your pages. These controls are Telerik.Cms.Web.UI.JsFileLink and Telerik.Cms.Web.UI.CssFileLink.

    You can use them by adding JsFileLink or CssFileLink as standard custom controls in your templates and setting the very few properties they have. See them in action in [your_website]\Sitefinity\ControlTemplates\Libraries\GalleryLightboxListTemplate.ascx. Here is how they serve the purpose of the Lightbox-enabled template:

    <sfWeb:CssFileLink ID="CssFileLink1" FileName="~/Sitefinity/ControlTemplates/Libraries/librariesCommonLayout.css" Media="screen" runat="server" /> 
    <sfWeb:CssFileLink ID="CssFileLink" FileName="~/Sitefinity/ExternalLibraries/lightbox/css/lightbox.css" Media="screen" runat="server" /> 
    <sfWeb:JsFileLink ID="PrototypeLink" runat="server" FileName="~/Sitefinity/ExternalLibraries/lightbox/js/prototype.js" /> 
    <sfWeb:JsFileLink ID="ScriptaculousLink" runat="server" FileName="~/Sitefinity/ExternalLibraries/lightbox/js/scriptaculous.js?load=effects" /> 
    <sfWeb:JsFileLink ID="JsFileLink2" runat="server" FileName="~/Sitefinity/ExternalLibraries/lightbox/js/lightbox.js" /> 

    We still do not support these controls as they are not mature enough and should have tons of features added in order to be officially announced and documented but I think they can come in handy in many situations.

    Hope this helps!

    Greetings,
    Tihomir
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. Erik
    Erik avatar
    34 posts
    Registered:
    06 Dec 2007
    27 Mar 2008
    Link to this post
    By including javascript <script> tags in a Generic Content control, won't this produce invalid HTML since the script tags won't be included in the <head> portion of the document?

    Just another concern since it may matter for folks like me who must validate their pages for legal reasons,

    Erik
  10. Rebecca
    Rebecca avatar
    536 posts
    Registered:
    24 Sep 2012
    28 Mar 2008
    Link to this post
    Hi Erik,

    You are free to opt for either of these. RadEditor produces valid XHTML so don't worry about this.

    Kind regards,
    Rebecca
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  11. Jeffrey
    Jeffrey avatar
    17 posts
    Registered:
    11 Nov 2010
    22 Dec 2010
    Link to this post
    How can I add javascript in 3.2? The EditorConfigFile.xml seems to no longer exist.

    Thanks,

    Jeff
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Dec 2010
    Link to this post
    Hi Kelly,

    The files is called EditorToolsFile.xml and it is inside Sitefinity/Admin/ControlTempaltes folder.
    You can also use JsFileLink control as suggested above.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Barry
    Barry avatar
    8 posts
    Registered:
    30 Dec 2010
    30 Dec 2010
    Link to this post
    I am using version 3.6 of Sitefinity (3.2 base install w/ 3.6 patch)

    I have tried adding the following to EditorToolsFile.xml but after adding javascript to a page using a GenericContent section, the script is stripped after saving and coming back to the edit control.

    <property name="AllowScripts">true</property>

     

    Where in the file EditorToolsFile.xml should this element exist?  I have placed it directly under the root, possibly I have it in the wrong location?

    Also, is this this preferred approach to allowing scripts in version 3.6?  I have also read about using the EditorTemplate.ascx file under \Sitefinity\Admin\ControlTemplates\Generic_Content althought  I could not get AllowScripts or ContentFilters  to work there either.

    Thank you for your assistance!

    Regards,

    -bds

     

     

  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    31 Dec 2010
    Link to this post
    Hello Kelly,

    1. You should map the external template for Generic Content control - GenericContentDesigner.ascx

    2. Then change the RadEditor content filters

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. Barry
    Barry avatar
    8 posts
    Registered:
    30 Dec 2010
    03 Jan 2011
    Link to this post
    Hello Ivan -

    Thank you for the information.  I am currently running version 3.6.1861.220.

    In reviewing the download archives for this version, I do not see the external templates as a seperate download for this version.  Can you direct me to where I can locate these so I can complete the steps that you provided?

    Thank you.

    Regards,

    -bds
  16. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Jan 2011
    Link to this post
    Hi Kelly,

    Please navigate to this section of your account

    Home / Your Account / Your products / Sitefinity 3.x and older versions

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  17. Barry
    Barry avatar
    8 posts
    Registered:
    30 Dec 2010
    03 Jan 2011
    Link to this post
    Hello Ivan -

    As I eluded to in my last reply, the external templates are not available as separate download in the location that you  specified for version 3.6.1861.  I am referring to http://www.sitefinity.com/account/your-products/product-versions.aspx?pid=463 and http://www.sitefinity.com/account/your-products/product-versions/single-download.aspx?pmvid=1726&pid=0 specifically.

    Can you please let me know specifically where I can obtain the external templates for version 3.6.1861?

    Thank you.

    Regards,

    -bds
  18. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 Jan 2011
    Link to this post
    Hello Kelly,

    If you have checked the Sitefinity 3.x and older versions you would find the downloads to all versions of Sitefinity.

    http://www.sitefinity.com/account/your-products/trial-product-versions.aspx?pid=463

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. Barry
    Barry avatar
    8 posts
    Registered:
    30 Dec 2010
    03 Jan 2011
    Link to this post
    Ivan -

    I have checked the URL that you provided and as I mentioned in my last reply, I have checked the page that contains the older versions http://www.sitefinity.com/account/your-products/product-versions.aspx?pid=463.  Each of these URLs contains the page for version 3.6 (3.6.1861) located at http://www.sitefinity.com/account/your-products/product-versions/single-download.aspx?pmvid=1726&pid=0.  However, this page does  NOT include the  separate download  for the external templates.  The first occurance of the external templates as a separate download that I could locate is for version 3.6 Hotfix (3.6.1870).

    I am running version 3.6.1861 and can not locate the external templates for this specific version.  I apologize if I am overlooking something, but can you please provide me the specific URL so that I can download the external templates for version 3.6.1861?

    Thank you.

    Regards,

    -bds
  20. Barry
    Barry avatar
    8 posts
    Registered:
    30 Dec 2010
    05 Jan 2011
    Link to this post
    Hello Ivan -

    Just checking-in on status, can you provide the URL for the 3.6.1861 external templates?

    If they are not available for 3.6.1861, can you provide the step-by-step process required to enable javascript in version 3.6.1861?

    Thank you.

    Regards,

    -bds
  21. Barry
    Barry avatar
    8 posts
    Registered:
    30 Dec 2010
    10 Jan 2011
    Link to this post
    Ivan -

    Can you please provide the URL for the download link for external templates for version 3.6.1861?

    If the external templates are not available for version 3.6.1861, can you please provide the step-by-step process for enabling javascript in a Generic Content block for this version?

    Thank you.

    Regards,

    -bds
  22. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Jan 2011
    Link to this post
    Hi Kelly,

    I attached external templates for Sitefintiy 3.6 1861. I suggest that you should upgrade your project to 3.7 or later version - 3.7 SP4, because we have mixed many bugs since 3.6.1861 and some of them are related to the templates.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
22 posts, 0 answered