Need Correct Syntax to add JS Script file to HEAD with STYLEHELPER

Nov 7, 2012 at 4:26 PM
Edited Nov 7, 2012 at 5:34 PM

I have several scripts where i need to add some js scripts to the head of a skin. After reading the documentation... i'm not understanding clearly  what the exact syntax should be. All i see is "AddJSFile=" which is fine but somewhere my syntax is wrong... I think this style helper IS GREAT! However, just needing some help in the right direction... see below..

I've already successfully added my style css successfully, as shown below:

<fortyfingers:STYLEHELPER ID="INCLUDE" AddToHead='<meta name="viewport" content="initial-scale = 1.0">' AddCssFile="style.css" media="screen" runat="server" />

HOWEVER The next line of adding a simple JS script is Not Working:

<fortyfingers:STYLEHELPER ID="INCLUDE" AddToHead='<script type="text/javascript"></script>' AddJSFile=myjsfile.js" runat="server" />

 

Together they look like this:

<fortyfingers:STYLEHELPER ID="INCLUDE" AddToHead='<meta name="viewport" content="initial-scale = 1.0">' AddCssFile="style.css" media="screen" runat="server" />
<fortyfingers:STYLEHELPER ID="INCLUDE" AddToHead='<script type="text/javascript"></script>' AddJSFile=myjsfile.js" runat="server" />

 

Please help me with the correct sytax to add JS scripts.
Eagerly awaiting an answer.

Coordinator
Nov 7, 2012 at 9:05 PM

Hi,

You either use AddToHead or you use AddJsFile, there's no connection between the two.

When you remove the AddtoHead and add a " before the js file-name you should be fine (if the js file is in the skin folder).

BTW, you are using the same ID for the two skin objects, which is not allowed, change one into id="Include2"

 

<fortyfingers:STYLEHELPER ID="INCLUDE" AddToHead='<meta name="viewport" content="initial-scale = 1.0">' AddCssFile="style.css" media="screen" runat="server" />
<fortyfingers:STYLEHELPER ID="INCLUDE2" AddJSFile="myjsfile.js" runat="server" />

Or combine to one

<fortyfingers:STYLEHELPER ID="INCLUDE" AddToHead='<meta name="viewport" content="initial-scale = 1.0">' AddCssFile="style.css" AddJSFile="myjsfile.js" CssMedia="screen" />
HTH Timo
Nov 8, 2012 at 2:09 PM

Understood...

Thanks so much for the clarity and providing an actual example code snippet.

Very appreciative.

R