getFolderName SiteCatalyst Plug-in

The getFolderName plug-in captures a folder name from the URL of a web page. Once captured, the value can be populated into any other JavaScript variable.

Plug-in Prototype

Parameter Descriptions
f=number of which folder in the URL that is to be captured.

Here is an example use of the plug-in to populate a s.prop variable with the name value of the folder noted in the function call.

For the URL

s.prop1=s.getFolderName(1); — would return apple
s.prop1=s.getFolderName(2); — would return orange
s.prop1=s.getFolderName(3); — would return pear


 * Plugin getFolderName
s.getFolderName=new Function("n","" 
+"var p=s.wd.location.pathname.substring(0, document.location.pathname.lastIndexOf('/') + 1),pa=p.split('/');if(pa[0]==''){for(var " 
+"i=0;i<pa.length;i++){pa[i]=i!=pa.length?pa[i+1]:null;}}return n?pa["