CFLib.org – Common Function Library Project

jsLocation(href)

Last updated May 9, 2003

author

Isaac Dealey

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
This udf takes a url and an optional frame argument and returns a small javascript which replaces the browser's current location in the browser's history stack with the url provided. This can be used after a cfflush tag and to the user is identical to the cflocation tag, preserving the browser's back button and works for both Netscape Navigator and MS Internet Explorer 3.0 and later.

Return Values:
Returns a string.

Example:

<cfif not isdefined("url.hello")>
<cfoutput>#jslocation(cgi.script_name & "?" & cgi.query_string & "&hello=world")#</cfoutput>
</cfif>

Parameters:

Name Description Required
href New url. Yes

Full UDF Source:

/**
 * A javascript alternative to the cflocation tag.
 * 
 * @param href 	 New url. (Required)
 * @return Returns a string. 
 * @author Isaac Dealey (info@turnkey.to) 
 * @version 1, May 9, 2003 
 */
function jslocation(href) { 
	var frame = "window"; 
		
	if (arraylen(arguments) gte 2) { frame = arguments[2]; } 
		
	return "<script language=""javascript"" type=""text/javascript"">" 
		& frame & ".location.replace(""" & jsstringformat(href) & """);</script>";
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson