Copy link to clipboard
Copied
Hi,
I have been using coldfusion to generate pages on my server. However I have noticed that coldfusion seems to be generating the code below before the main code of the page. This seems to be affecting code trying to resolve compatibility mode issues in Internet Explorer, etc.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
</body>
</html>
Can anyone please advise if they know why this would be happening?
Many thanks!
Copy link to clipboard
Copied
ColdFusion is not responsible for sending HTML content to the browser. That is the job of the web server.
In any case, could you show us an example of your code?
Copy link to clipboard
Copied
So is this to do with the IIS on our server?
The code is normal coldfusion code:
<cfquery name="queryname" datasource="dsn">
select field_name from table_name
</cfquery>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>...</title>...
However, as mentioned, the empty code above appears before this when I view page source.
Copy link to clipboard
Copied
Under what name did you save the file?
Copy link to clipboard
Copied
This occurs regardless what the file name is (index.cfm, profile.cfm, etc).
What I have noticed that the code generated on a page where a cfform tag exists is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script type="text/javascript" src="/CFIDE/scripts/cfform.js"></script>
<script type="text/javascript" src="/CFIDE/scripts/masks.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
<!--
_CF_checkCFForm_1 = function(_CF_this)
{
//reset on submit
_CF_error_exists = false;
_CF_error_messages = new Array();
_CF_error_fields = new Object();
_CF_FirstErrorField = null;
//display error messages and return success
if( _CF_error_exists )
{
if( _CF_error_messages.length > 0 )
{
// show alert() message
_CF_onErrorAlert(_CF_error_messages);
// set focus to first form error, if the field supports js focus().
if( _CF_this[_CF_FirstErrorField].type == "text" )
{ _CF_this[_CF_FirstErrorField].focus(); }
}
return false;
}else {
return true;
}
}
//-->
</script>
</head>
<body>
</body>
</html>
​Hope this helps!
Copy link to clipboard
Copied
That is the intended functionality. The tag, cfform, instructs ColdFusion to apply its in-built capability to generate a form, together with the accompanying Javascript. If you don't want that, then you should use <form> instead.
If you wish to obtain an ordinary page, it will be sufficient to do something like this:
<cfquery name="queryname" datasource="dsn">
select field_name from table_name
</cfquery>
<cfdump var = "#queryname#">
Copy link to clipboard
Copied
When having just the query and dumping the query as your suggestion, there is still an empty body tag generated before the query shows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
</body>
</html>
<style>
table.cfdump_wddx,
table.cfdump_xml,
table.cfdump_struct,
table.cfdump_varundefined,
table.cfdump_array,
table.cfdump_query,
table.cfdump_cfc,
table.cfdump_object,
table.cfdump_binary,
table.cfdump_udf,
table.cfdump_udfbody,
table.cfdump_udfarguments {
font-size: xx-small;
font-family: verdana, arial, helvetica, sans-serif;
cell-spacing: 2px;
}
...
...
Copy link to clipboard
Copied
Then something is amiss. Try 2 things:
1) Just to rule out, do an extended search of your code base to find out where you might be including the html tags.
2) This might be a browser quirk, so try a different browser.
Copy link to clipboard
Copied
I can't see anything that might include html in the code I'm using.
This occurs on IE, Chrome and Firefox
Copy link to clipboard
Copied
You might be having an unexplained error. Check the logs.
Copy link to clipboard
Copied
Another suggestion, more or less a stab in the dark: implement the following method in your Application.cfc
<cffunction name="onRequest">
<cfargument name = "targetPage" type="String" required=true/>
<cfsavecontent variable="pageContent">
<cfinclude template="#arguments.targetPage#">
</cfsavecontent>
<cfif findNoCase("table.cfdump_wddx,", pageContent) gt 0>
The string "table.cfdump_wddx," was found in the page, <cfoutput>#arguments.targetPage#</cfoutput><cfabort>
</cfif>
</cffunction>
Copy link to clipboard
Copied
Thanks again for your help. The function within the application file doesn't seem to be affecting anything.