Reputation: 789
I am creating a back button. I am trying to to create the url where the go back button will use to redirect the user to the indicated page.
The url path that is being passed is is the following: " /Public/Health Plans/Compliance Resources/Policies/...."
However, when I do a console.log on to see how the url is being read, I am seeing the following: /PublicHealth PlansCompliance ResourcesPolicies....
I also see that the url is also missing parts of the directory.
My question is: How can I get the url to read as /Public/Health Plans/Compliance Resources/Policies/....? And not have the full path be cut off?
Here is the following JS:
<script>
$(document).ready(function(e){
<cfif structKeyExists(URL, 'directory')>
console.log(<cfoutput>"#URLEncodedFormat(URL.directory)#"</cfoutput>, "<--URL directory");
$('.prev').click(function(){
var curent_directory = <cfoutput>#toScript(previous_directory, 'curent_directory')#</cfoutput>;
var array = curent_directory.split("\\");
var new_directory = "";
for(var x = 0; x < array.length-1; x++){
new_directory += array[x] + "\\";
}
var update_directory = new_directory.substring(0, new_directory.length - 1); <!--- removes "\" at the end --->
var i = update_directory.replace(/\\\//g, "base64");
console.log(i);
var prev_subfolder = array.reverse()[0]; <!--- Grabs the previous folder name --->
<!--- Go Back Link --->
window.location.href = "HPN_Compliance_Policies.cfm?directory=" + i + "&subfolder=" + prev_subfolder + "&count=<cfoutput>#counter-2#</cfoutput>";
});
</cfif>
});
</script>
Upvotes: 0
Views: 84
Reputation: 789
I would like thank those who looked or replied to help me with my question. I was able to figure it out by looking into ColdFusion and was able to do the following (if anyone is interested/future reference):
<!--- Following is create the "Go Back" button url link --->
<cfset current_url = URL.directory />
<cfset prev_folder = ListLast(URL.directory, '\') /> <!--- Grabs the last item of the URL --->
<cfset new_url = Replace(current_url, "\#prev_folder#","") /><!--- Create previous directory --->
<!--- =================================================== --->
Upvotes: 1