Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
The javascript runs when the html body loads. However, it never loads because the the cflocation tag is before the closing body tag.
Copy link to clipboard
Copied
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