Skip to main content
Inspiring
November 9, 2009
Question

cflocation redirect

  • November 9, 2009
  • 2 replies
  • 705 views

Hi,

i have written  follwing code in coldfusion page

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function test()
{
location.href='test1.cfm';
}
</script>

</head>

<body onLoad="test()">

<cflocation url="test.cfm" addtoken="no">

</body>
</html>

while excuting this page cflocation url is excuting first not javascript url why this happens?

Advance thanks

This topic has been closed for replies.

2 replies

Inspiring
November 9, 2009

CFML runs on the CF server long before the mark-up gets sent to the client browser.  Indeed in this case, no mark-up gets sent to the borser because as soon as CF encounters the <cflocation> it sends a redirect response to the client browser, which is done solely by sending a HTTP header, with no content at all.

--

Adam

Inspiring
November 9, 2009

The javascript runs when the html body loads.  However, it never loads because the the cflocation tag is before the closing body tag.