Announcement

Collapse
No announcement yet.

External javascript and Actinic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    External javascript and Actinic

    I am currently in the process of redesigning an Actinic site whilst trying to incorporate a lot of the features that are discussed in the Advanced Users' Guide. The scripts have all worked very well until I attempted to put them in an external file in an attempt to keep the <HEAD> section clean.

    I am curious as to whether or not it is possible to accomplish this. My main concern is that all the scripts require the inclusion of:
    Code:
    <!--@act NETQUOTEVAR:X -->
    I understand that Actinic fills this in automatically upon generation of its pages. However, once this is moved to an external file, I am unsure if it will - or if there is any method of forcing it to - fill in this tag.

    In an attempt to test this method, I have created an Act_Primary.html that consists of nothing more than the essential Actinic tags in the head as well as:
    Code:
    <SCRIPT LANGUAGE="JavaScript" SRC="functions.js" TYPE="text/javascript"></SCRIPT>
    In the body, I have limited the page to:
    Code:
    <form name="Act_SectionDroplist">
            <script type="text/javascript" src="stinkyink.js"></script>
    </form>
    This is the implementation of the script described in the Advanced Users' Guide that should produce a drop down form of all parent sections in the database.

    I then have an external file, 'functions.js', which currently contains the script for the form element:

    Code:
    <!--@act NETQUOTEVAR:TOPLEVELSECTIONS_RAW -->
    
    function ACT_DropListBox(ar)
    	{
    	var strIDs = '<SELECT SIZE="1" NAME="ACT_droplstbox" onClick="if(options[selectedIndex].value) window.location.href=(options[selectedIndex].value)">'
      	var sel = " SELECTED"
      	strIDs += '<OPTION ' + sel + ' VALUE="">Select a Section</OPTION>'
      	for (var i=1;i<=ar.length;i++)
      		{
    		if (ar[i].sURL !=null)
    			{
    			strIDs += '<OPTION VALUE="' + ar[i].sURL + '">' + ar[i].sName + '</OPTION>'
    			}
      		}
    	strIDs+='</SELECT>'
      	return strIDs
      	}
    As of yet, this method has yielded no results, merely script errors. It should also be noted that <!--@act NETQUOTEVAR:TOPLEVELSECTIONS_RAW --> has been placed in the page's <HEAD> on the off chance it might do something.

    I should be very interested, had anyone managed to get these scripts to work externally from the page. Any help in the matter would be very much appreciated, as leaving the scripts in the page's <HEAD> is untidy practice, and is detrimental to the process of optimising the site for search engines.

    #2
    Hi there

    In your Act_Primary.html in the head section have it as shown:

    Code:
    <!--@act NETQUOTEVAR:TOPLEVELSECTIONS_RAW -->
    <SCRIPT LANGUAGE="JavaScript" SRC="functions.js" TYPE="text/javascript"></SCRIPT>
    This should then work fine. I'm afraid you cannot move the variable to an external javascript function.

    Kind Regards
    Nadeem Rasool
    SellerDeck Development

    Comment


      #3
      I regularly use external javaScript files in my Primary Templates. E.g.

      <SCRIPT LANGUAGE="JavaScript" SRC="upsellsupport.js" TYPE="text/javascript"></SCRIPT>

      Actinic detects these filenames and uploads them to the server automatically.

      What you can't do is include NETQUOTEVARS in these external JavaScript files as Actinic does not parse them in any way.

      If you do need NETQUOTEVARS in these external files then you have to put them into JavaScript variables, which your included files then have access to.

      E.g.

      <script language=JavaScript>
      <!--
      var basehref='NETQUOTEVAR:BASEHREF';
      //-->
      </script>
      <SCRIPT LANGUAGE="JavaScript" SRC="upsellsupport.js" TYPE="text/javascript"></SCRIPT>

      This way you have a minimal amount of inline code, wiith the bulk in an external (and hopefully cached) file.

      Finally, if you're getting JavaScript errors the best way to diagnose what's wrong is to view the page with Firefox and use it's Tools / JavaScript Console for sensible diagnostics, rather than IE's useless ones.
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment

      Working...
      X