CFLib.org – Common Function Library Project

jsLocation(href)

Last updated May 09, 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>";
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson