Allowing web editors to add javascript in EPiServer
March 13, 2007
I haven’t got much to do right now, except for some really small and easy EPiServer thingees. This is one of them:
The customer wanted to allow the web editors to add javascript in the Edit Mode that was then included in the <head> of the page. Easy to do.
1. Add the following code to the header.ascx file:
<%=GetJavaScript()%>
2. Then put the following method in the code-behind file:
protected string GetJavaScript()
{
if(CurrentPage.Property.Exists("Javascript"))
{
return CurrentPage.Property["Javascript"].ToString();
}
else
{
return String.Empty;
}
}
3. Add an XHTML property called “Javascript” to any pages where you wish to have javascript.
4. Write/paste the javascript in the text box for this property. However, make sure that you paste it in the HTML edit mode, not ordinary text mode. Otherwise EPiServer will just reformat your javascript to html, which isn’t pretty.
September 7, 2009 at 15:25
is there a way to fast att Google analytics code (i.e JavaScript) manually for a non episerver developer?